diff --git a/client.go b/client.go index 1ab651d..f4762bb 100644 --- a/client.go +++ b/client.go @@ -7,9 +7,9 @@ import ( ) const ( - webSocketProtocol = "ws://" + webSocketProtocol = "ws://" webSocketSecureProtocol = "wss://" - socketioUrl = "/socket.io/?EIO=3&transport=websocket" + socketioUrl = "/socket.io/?EIO=3&transport=websocket" ) /** @@ -22,7 +22,7 @@ type Client struct { /** Get ws/wss url by host and port - */ +*/ func GetUrl(host string, port int, secure bool) string { var prefix string if secure { diff --git a/loop.go b/loop.go index 0955a1d..21f803f 100644 --- a/loop.go +++ b/loop.go @@ -137,7 +137,6 @@ func inLoop(c *Channel, m *methods) error { go m.processIncomingMessage(c, msg) } } - return nil } var overflooded map[*Channel]struct{} = make(map[*Channel]struct{}) @@ -178,7 +177,6 @@ func outLoop(c *Channel, m *methods) error { return closeChannel(c, m, err) } } - return nil } /** diff --git a/protocol/message.go b/protocol/message.go index 3ba9d81..24d1141 100644 --- a/protocol/message.go +++ b/protocol/message.go @@ -42,4 +42,3 @@ type Message struct { Args string Source string } - diff --git a/protocol/socketio.go b/protocol/socketio.go index ae8b81d..527f9c5 100644 --- a/protocol/socketio.go +++ b/protocol/socketio.go @@ -15,8 +15,8 @@ const ( ackMessage = "43" CloseMessage = "1" - PingMessage = "2" - PongMessage = "3" + PingMessage = "2" + PongMessage = "3" ) var ( diff --git a/server.go b/server.go index 14af902..235a603 100644 --- a/server.go +++ b/server.go @@ -44,7 +44,7 @@ type Server struct { /** Close current channel - */ +*/ func (c *Channel) Close() { if c.server != nil { closeChannel(c, &c.server.methods) @@ -238,7 +238,7 @@ func (s *Server) BroadcastToAll(method string, args interface{}) { Generate new id for socket.io connection */ func generateNewId(custom string) string { - hash := fmt.Sprintf("%s %s %n %n", custom, time.Now(), rand.Uint32(), rand.Uint32()) + hash := fmt.Sprintf("%s %s %d %d", custom, time.Now(), rand.Uint32(), rand.Uint32()) buf := bytes.NewBuffer(nil) sum := md5.Sum([]byte(hash)) encoder := base64.NewEncoder(base64.URLEncoding, buf) diff --git a/transport/websocket.go b/transport/websocket.go index 58da673..10e6bea 100644 --- a/transport/websocket.go +++ b/transport/websocket.go @@ -2,14 +2,16 @@ package transport import ( "errors" - "github.com/gorilla/websocket" "io/ioutil" + "log" "net/http" "time" + + "github.com/gorilla/websocket" ) const ( - upgradeFailed = "Upgrade failed: " + upgradeFailed = "Upgrade failed: " WsDefaultPingInterval = 30 * time.Second WsDefaultPingTimeout = 60 * time.Second