Commit 34e55e19 by 段启岩

加入socket.io跨域

parent 44cf433d
......@@ -24,9 +24,7 @@ public class SocketIOConfig {
config.setBossThreads(1);
config.setAllowCustomRequests(true);
// Ping消息超时时间(毫秒),默认60秒,这个时间间隔内没有接收到心跳消息就会发送超时事件
config.setPingTimeout(180000);
// Ping消息间隔(毫秒),默认25秒。客户端向服务器发送一条心跳消息间隔
config.setPingInterval(60000);
return new SocketIOServer(config);
}
......
......@@ -5,6 +5,7 @@ import com.corundumstudio.socketio.SocketIOClient;
import com.corundumstudio.socketio.SocketIOServer;
import com.corundumstudio.socketio.protocol.Packet;
import com.corundumstudio.socketio.protocol.PacketType;
import io.netty.handler.codec.http.websocketx.PongWebSocketFrame;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -97,10 +98,6 @@ public class SocketIOServiceImpl implements SocketIOService {
}
});
socketIOServer.addPingListener(client -> {
client.send(new Packet(PacketType.PONG));
});
socketIOServer.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