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.34k stars 975 forks source link

How to customize the default URL(/socket.io/?EIO=...) in client and server? #661

Closed Tracy0725 closed 3 years ago

Tracy0725 commented 3 years ago

I want to customize the default URL such as /MySocket/?EIO=...

darrachequesne commented 3 years ago

I think you are looking for the path option:

IO.Options options = IO.Options.builder()
        .setPath("/MySocket/")
        .build();

Socket socket = IO.socket(URI.create("https://example.com"), options);

Documentation: https://socketio.github.io/socket.io-client-java/initialization.html#path

Tracy0725 commented 3 years ago

I think you are looking for the path option:

IO.Options options = IO.Options.builder()
        .setPath("/MySocket/")
        .build();

Socket socket = IO.socket(URI.create("https://example.com"), options);

Documentation: https://socketio.github.io/socket.io-client-java/initialization.html#path

Yes, thanks! and Attach the method in server. In client:

 IO.Options options = new IO.Options();
options.path = "/custom.socket.io";

In server:

com.corundumstudio.socketio.Configuration config = new com.corundumstudio.socketio.Configuration();
config.setContext("/custom.socket.io");