服务器实例
创建服务器
Configuration config = new Configuration();
config.setHostname("localhost");
config.setPort(9092);
SocketIOServer server = new SocketIOServer(config);启动服务器
server.start()server.startAsync().addListener(future -> {
if (future.isSuccess()) {
System.out.println("Server started on " + config.getPort());
} else {
System.out.println("Error " + future.cause().getLocalizedMessage());
}
});停止服务器
server.stop();完整示例
注意
最后更新于
这有帮助吗?