go-socket.io
go-socket.io copied to clipboard
How to bind events for sio.Conn in v1.4 ?
In old version of go-socket.io, I use this code to auth my clients:
Server.On("auth", func(client sio.Socket, token string) {
if token != "xxxx"{ // token auth
return
}
client.Join("/")
client.On("cmd1", CmdHandler) // bind events for authed client
client.On("cmd2", CmdHandler)
SocketioPool[client.Id()] = client
...
}
// the client who authed success can send command to server.
But in new version of go-socket.io, it seems I can only bind events in global use method server.OnEvent(...)
. How could I bind events for single Connection in new version 1.4?