mirror of
https://github.com/nadoo/glider.git
synced 2026-11-19 07:09:42 +08:00
wss: optimize server code
This commit is contained in:
1 parent
63caac133d
commit
346db3338e
5 files changed
+30
-31
No files matched your search
+4
-4
@@ -91,8 +91,8 @@ func (s *WS) ListenAndServe() {
|
||||
func (s *WS) Serve(cc net.Conn) {
|
||||
if s.withTLS {
|
||||
tlsConn := tls.Server(cc, s.tlsConfig)
|
||||
err := tlsConn.Handshake()
|
||||
if err != nil {
|
||||
if err := tlsConn.Handshake(); err != nil {
|
||||
tlsConn.Close()
|
||||
log.F("[ws] error in tls handshake: %s", err)
|
||||
return
|
||||
}
|
||||
@@ -101,6 +101,7 @@ func (s *WS) Serve(cc net.Conn) {
|
||||
|
||||
c, err := s.NewServerConn(cc)
|
||||
if err != nil {
|
||||
c.Close()
|
||||
log.F("[ws] handshake error: %s", err)
|
||||
return
|
||||
}
|
||||
@@ -143,8 +144,7 @@ type ServerConn struct {
|
||||
// NewServerConn creates a new ws server connection.
|
||||
func (s *WS) NewServerConn(rc net.Conn) (*ServerConn, error) {
|
||||
sc := &ServerConn{Conn: rc}
|
||||
err := sc.Handshake(s.host, s.path)
|
||||
return sc, err
|
||||
return sc, sc.Handshake(s.host, s.path)
|
||||
}
|
||||
|
||||
// Handshake handshakes with the client.
|
||||
|
||||
Reference in new issue
Block a user