Commit 34e55e19 by 段启岩

加入socket.io跨域

parent 44cf433d
...@@ -24,9 +24,7 @@ public class SocketIOConfig { ...@@ -24,9 +24,7 @@ public class SocketIOConfig {
config.setBossThreads(1); config.setBossThreads(1);
config.setAllowCustomRequests(true); config.setAllowCustomRequests(true);
// Ping消息超时时间(毫秒),默认60秒,这个时间间隔内没有接收到心跳消息就会发送超时事件 // Ping消息超时时间(毫秒),默认60秒,这个时间间隔内没有接收到心跳消息就会发送超时事件
config.setPingTimeout(180000);
// Ping消息间隔(毫秒),默认25秒。客户端向服务器发送一条心跳消息间隔 // Ping消息间隔(毫秒),默认25秒。客户端向服务器发送一条心跳消息间隔
config.setPingInterval(60000);
return new SocketIOServer(config); return new SocketIOServer(config);
} }
......
...@@ -5,6 +5,7 @@ import com.corundumstudio.socketio.SocketIOClient; ...@@ -5,6 +5,7 @@ import com.corundumstudio.socketio.SocketIOClient;
import com.corundumstudio.socketio.SocketIOServer; import com.corundumstudio.socketio.SocketIOServer;
import com.corundumstudio.socketio.protocol.Packet; import com.corundumstudio.socketio.protocol.Packet;
import com.corundumstudio.socketio.protocol.PacketType; import com.corundumstudio.socketio.protocol.PacketType;
import io.netty.handler.codec.http.websocketx.PongWebSocketFrame;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -97,10 +98,6 @@ public class SocketIOServiceImpl implements SocketIOService { ...@@ -97,10 +98,6 @@ public class SocketIOServiceImpl implements SocketIOService {
} }
}); });
socketIOServer.addPingListener(client -> {
client.send(new Packet(PacketType.PONG));
});
socketIOServer.start(); socketIOServer.start();
System.out.println("SOCKET SERVER START."); System.out.println("SOCKET SERVER START.");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment