[英]How to customise handshake url of socket io server in JAVA
I need to start a socket io server by using the Netty socket io library in java. 我需要使用Java中的Netty套接字io库来启动套接字io服务器。 And that should be connected by the client with a custom URL.
客户端应使用自定义网址进行连接。
Normal handshake URL should be like :- http://192.168.1.190:8021/socket.io/?EIO=3&transport=polling&t=15669875 正常的握手URL应该类似于: -http : //192.168.1.190 : 8021/socket.io/?EIO=3&transport=polling&t=15669875
But I need to customise it like follows, how should I do that. 但是我需要像下面这样自定义它,我该怎么做。 http://192.168.1.190:8021/myapp/socket.io/?EIO=3&transport=polling&t=15669875
http://192.168.1.190:8021/myapp/socket.io/?EIO=3&transport=polling&t=15669875
Code for socket server 套接字服务器的代码
public void start() {
Configuration config = new Configuration();
config.setHostname(hostIP);
config.setPort(hostPort);
socketServer = new SocketIOServer(config);
// For collecting Socket client ID
socketServer.addEventListener("Topic", SocketNotificationData.class,
new DataListener<SocketNotificationData>() {
@Override
public void onData(final SocketIOClient client, SocketNotificationData data, final AckRequest ackRequest) throws Exception {
logger.info(" ----------One socket-- client id - "
+ client.getSessionId().toString());
}
});
socketServer.start();
}
Later I find out the answer 后来我找出答案
Configuration config = new Configuration();
config.setHostname(hostIP);
config.setPort(hostPort);
config.setContext("/myapp");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.