|
95 | 95 | importorg.jboss.netty.handler.codec.http.HttpVersion; |
96 | 96 | importorg.jboss.netty.handler.codec.http.websocketx.BinaryWebSocketFrame; |
97 | 97 | importorg.jboss.netty.handler.codec.http.websocketx.CloseWebSocketFrame; |
| 98 | +importorg.jboss.netty.handler.codec.http.websocketx.PingWebSocketFrame; |
| 99 | +importorg.jboss.netty.handler.codec.http.websocketx.PongWebSocketFrame; |
98 | 100 | importorg.jboss.netty.handler.codec.http.websocketx.TextWebSocketFrame; |
99 | 101 | importorg.jboss.netty.handler.codec.http.websocketx.WebSocket08FrameDecoder; |
100 | 102 | importorg.jboss.netty.handler.codec.http.websocketx.WebSocket08FrameEncoder; |
@@ -2274,6 +2276,8 @@ private final class WebSocketProtocol implements Protocol { |
2274 | 2276 | privatestaticfinalbyteOPCODE_CONT =0x0; |
2275 | 2277 | privatestaticfinalbyteOPCODE_TEXT =0x1; |
2276 | 2278 | privatestaticfinalbyteOPCODE_BINARY =0x2; |
| 2279 | +privatestaticfinalbyteOPCODE_PING =0x9; |
| 2280 | +privatestaticfinalbyteOPCODE_PONG =0xa; |
2277 | 2281 | privatestaticfinalbyteOPCODE_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 | }elseif (frameinstanceofBinaryWebSocketFrame) { |
2378 | 2382 | pendingOpcode =OPCODE_BINARY; |
| 2383 | + }elseif (frameinstanceofPingWebSocketFrame) { |
| 2384 | +pendingOpcode =OPCODE_PING; |
| 2385 | + }elseif (frameinstanceofPongWebSocketFrame) { |
| 2386 | +pendingOpcode =OPCODE_PONG; |
2379 | 2387 | } |
2380 | 2388 |
|
2381 | 2389 | HttpChunkwebSocketChunk =newHttpChunk() { |
@@ -2409,6 +2417,10 @@ public void setContent(ChannelBuffer content) { |
2409 | 2417 | webSocket.onBinaryFragment(rp.getBodyPartBytes(),frame.isFinalFragment()); |
2410 | 2418 | }elseif (pendingOpcode ==OPCODE_TEXT) { |
2411 | 2419 | webSocket.onTextFragment(frame.getBinaryData().toString(UTF8),frame.isFinalFragment()); |
| 2420 | + }elseif (pendingOpcode ==OPCODE_PING) { |
| 2421 | +webSocket.onPing(rp.getBodyPartBytes()); |
| 2422 | + }elseif (pendingOpcode ==OPCODE_PONG) { |
| 2423 | +webSocket.onPong(rp.getBodyPartBytes()); |
2412 | 2424 | } |
2413 | 2425 |
|
2414 | 2426 | if (frameinstanceofCloseWebSocketFrame) { |
|