socketio / socket.io-client-java

Full-featured Socket.IO Client Library for Java, which is compatible with Socket.IO v1.0 and later.
https://socketio.github.io/socket.io-client-java/installation.html
Other
5.32k stars 972 forks source link

cant set HandShake message #688

Closed ylcinyakup closed 2 years ago

ylcinyakup commented 2 years ago

I want to connect v2 socketIo server. in javascript i receive data but i cant receive data with java. because i cant send custom handshake message.. can you help we with this issue ?

Socket.IO server version: v2

Socket.IO java client version: 1.0.1

Client


String handshake = "sample";
try {
            IO.Options options = new IO.Options();
            Socket socket = IO.socket(new URI(url), options);
            socket.connect();

            socket.on(Socket.EVENT_CONNECT, args12 -> System.out.println("connected"));
            socket.on(Socket.EVENT_CONNECT_ERROR, args13 -> System.out.println("connection error"));

            boolean connected = socket.connected();
            while (!connected) {
                Thread.sleep(1000);
                connected = socket.connected();
            }
            socket.send("handshake", handshake);
            socket.emit("handshake", handshake);
            socket.on("topic1", args1 -> System.out.println("topic1"));
            socket.on("topic2", args1 -> System.out.println("topic2"));
            boolean cn = socket.hasListeners("cn");
            boolean cs = socket.hasListeners("cs");
            while (true) {

                connected = socket.connected();
                System.out.println("asdasd" + connected);
                Thread.sleep(1000);

            }

Expected behavior connection success but never get a message. Because i cant send custom handshake message.

darrachequesne commented 2 years ago

Closed due to inactivity, please reopen if needed.