|
95 | 95 | import org.jboss.netty.handler.codec.http.HttpVersion;
|
96 | 96 | import org.jboss.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
|
97 | 97 | import org.jboss.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
|
| 98 | +import org.jboss.netty.handler.codec.http.websocketx.PingWebSocketFrame; |
| 99 | +import org.jboss.netty.handler.codec.http.websocketx.PongWebSocketFrame; |
98 | 100 | import org.jboss.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
99 | 101 | import org.jboss.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder;
|
100 | 102 | import org.jboss.netty.handler.codec.http.websocketx.WebSocket08FrameEncoder;
|
@@ -2274,6 +2276,8 @@ private final class WebSocketProtocol implements Protocol {
|
2274 | 2276 | private static final byte OPCODE_CONT = 0x0;
|
2275 | 2277 | private static final byte OPCODE_TEXT = 0x1;
|
2276 | 2278 | private static final byte OPCODE_BINARY = 0x2;
|
| 2279 | + private static final byte OPCODE_PING = 0x9; |
| 2280 | + private static final byte OPCODE_PONG = 0xa; |
2277 | 2281 | private static final byte OPCODE_UNKNOWN = -1;
|
2278 | 2282 |
|
2279 | 2283 | // We don't need to synchronize as replacing the "ws-decoder" will process using the same thread.
|
@@ -2376,6 +2380,10 @@ public void handle(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
|
2376 | 2380 | pendingOpcode = OPCODE_TEXT;
|
2377 | 2381 | } else if (frame instanceof BinaryWebSocketFrame) {
|
2378 | 2382 | pendingOpcode = OPCODE_BINARY;
|
| 2383 | + } else if (frame instanceof PingWebSocketFrame) { |
| 2384 | + pendingOpcode = OPCODE_PING; |
| 2385 | + } else if (frame instanceof PongWebSocketFrame) { |
| 2386 | + pendingOpcode = OPCODE_PONG; |
2379 | 2387 | }
|
2380 | 2388 |
|
2381 | 2389 | HttpChunk webSocketChunk = new HttpChunk() {
|
@@ -2409,6 +2417,10 @@ public void setContent(ChannelBuffer content) {
|
2409 | 2417 | webSocket.onBinaryFragment(rp.getBodyPartBytes(), frame.isFinalFragment());
|
2410 | 2418 | } else if (pendingOpcode == OPCODE_TEXT) {
|
2411 | 2419 | webSocket.onTextFragment(frame.getBinaryData().toString(UTF8), frame.isFinalFragment());
|
| 2420 | + } else if (pendingOpcode == OPCODE_PING) { |
| 2421 | + webSocket.onPing(rp.getBodyPartBytes()); |
| 2422 | + } else if (pendingOpcode == OPCODE_PONG) { |
| 2423 | + webSocket.onPong(rp.getBodyPartBytes()); |
2412 | 2424 | }
|
2413 | 2425 |
|
2414 | 2426 | if (frame instanceof CloseWebSocketFrame) {
|
|
0 commit comments