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

working on js socket.io but not in this library

Open codenoid opened this issue 5 years ago • 5 comments

is there any way to handle any incoming emit message without defining emit type ?

codenoid avatar Mar 25 '20 14:03 codenoid

i wonder, why this works :

io.on('connection', function (socket) {
    console.log("incoming")

    socket.on('test', function (data) {
        console.log(data);
    });
});

but not in Go version :

// OnConnect part are working
server.OnConnect("/", func(s socketio.Conn) error {
	fmt.Println("connected:", s.ID())
	return nil
})

server.OnEvent("/", "test", func(s socketio.Conn, msg string) {
	fmt.Println(s.URL())
	fmt.Println(s.Rooms())
	fmt.Println(s.RemoteAddr())
	fmt.Println(s.LocalAddr())
	fmt.Println("notice:", msg)
})

codenoid avatar Mar 25 '20 16:03 codenoid

can you post your client code / tell us the version of the client library you used?

adrianmxb avatar Mar 26 '20 17:03 adrianmxb

i use https://github.com/socketio/socket.io-client-java

the code :

IO.Options opts = new IO.Options();
opts.reconnection = true;
opts.reconnectionDelay = 5000;
opts.reconnectionDelayMax = 999999999;

ioSocket = IO.socket("http://192.168.8.101:42474");
ioSocket.emit("test", "hello".getBytes())

codenoid avatar Mar 26 '20 18:03 codenoid

@codenoid Do you can share simple working source code from java? What is your client library version?

sshaplygin avatar Apr 06 '20 17:04 sshaplygin

@mrfoe7 1.0.0 , from README.md

codenoid avatar Apr 07 '20 15:04 codenoid