go-socket.io
go-socket.io copied to clipboard
socket close does not work on disconnect ?
Hello,
In example I see that s.Close() is used on "bye" event. Is it possible to do it onDisconnect event after doing some operations?
When I do s.Close() on disconnect, I have "Did you forget to Close() the ReadCloser from NextReader?" after some time. But I closed it.
SocketIO in golang is a great work but I find it more complicated than before...
Regards
This issue duplicates to old issue #279
In example I see that s.Close() is used on "bye" event.
This message changed by "client namespace disconnect"
Is it possible to do it onDisconnect event after doing some operations?
What do you wanna print?
When I do s.Close() on disconnect, I have "Did you forget to Close() the ReadCloser from NextReader?" after some time. But I closed it.
It is so interesting. Please, Tell me about your socket.io-client version and golang version.
SocketIO in golang is a great work but I find it more complicated than before...
Thanks, but it is work by @googollee
Hello,
I'm with go v1.12.
I don't want to print anything but for example, here is my code :
server.OnDisconnect("/", func(s socketio.Conn, msg string) {
lenRoom := len(s.Rooms())
if lenRoom > 0 {
for i := 0; i < lenRoom; i++ {
log.Println("Socket id:", s.ID(), "left:", s.Rooms()[i])
server.LeaveRoom(s.Rooms()[i], s)
server.BroadcastToRoom(s.Rooms()[i], "nbr_connected", server.RoomLen(s.Rooms()[i])-1)
}
}
s.Close()
})
It's simple. But have this message when I use s.Close() here "Did you forget to Close() the ReadCloser from NextReader?"