go-socket.io icon indicating copy to clipboard operation
go-socket.io copied to clipboard

How to bind events for sio.Conn in v1.4 ?

Open enify opened this issue 5 years ago • 0 comments

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?

enify avatar Mar 25 '19 11:03 enify