Answer the question
In order to leave comments, you need to log in
Why don't rooms work?
Hello, I don't understand what is the problem. I want to create rooms, but nothing comes out. I do it like this:
r := mux.NewRouter()
r.Handle("/socket.io/", controllers.CreateSocketIoServer())
var server *socketio.Server
func CreateSocketIoServer() *socketio.Server {
server, _ = socketio.NewServer(nil)
log.Println("Socket.io - запущен")
return server
}
r.HandleFunc("/room/name", controllers.MainRoomHandle)
func MainRoomHandle(w http.ResponseWriter, r *http.Request) {
...
Chat(w, r)
}
func Chat(w http.ResponseWriter, r *http.Request) {
server.On("connection", func(so socketio.Socket) {
so.Join("1")
log.Println("connect 1")
so.On("disconnection", func() {
})
})
server.On("connection", func(so socketio.Socket) {
so.Join("2")
log.Println("connect 2")
so.On("disconnection", func() {
})
})
}
var room = io('')
room.on('connection', function(){
room.join('1');
});
Answer the question
In order to leave comments, you need to log in
What were you smoking before you thought of using this library in Go? I want that too. Use gorilla web sockets
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question