Chromium Code Reviews| Index: net/data/websocket/count-connection_wsh.py |
| diff --git a/net/data/websocket/close-with-split-packet_wsh.py b/net/data/websocket/count-connection_wsh.py |
| similarity index 50% |
| copy from net/data/websocket/close-with-split-packet_wsh.py |
| copy to net/data/websocket/count-connection_wsh.py |
| index 3bd5b58b25af1136c6f86c52a4c2e2fc144b11a3..e1c7cf7bc5a0644fc049c80e36c69aa1e21646e2 100644 |
| --- a/net/data/websocket/close-with-split-packet_wsh.py |
| +++ b/net/data/websocket/count-connection_wsh.py |
| @@ -4,22 +4,28 @@ |
| import struct |
|
Adam Rice
2014/07/14 10:31:31
Not used.
yhirano
2014/07/14 11:24:36
Done.
|
| +numOpenConnections = 0 |
| +numClosedConnections = 0 |
| + |
| from mod_pywebsocket import handshake |
|
Adam Rice
2014/07/14 10:31:30
Neither mod_pywebsocket import is used.
yhirano
2014/07/14 11:24:36
Done.
|
| from mod_pywebsocket import stream |
| -def web_socket_do_extra_handshake(_request): |
| - pass |
| +def web_socket_do_extra_handshake(request): |
| + global numOpenConnections |
| + numOpenConnections += 1 |
| def web_socket_transfer_data(request): |
| + request.ws_stream.send_message('open: %d, closed: %d' % |
| + (numOpenConnections, numClosedConnections), binary=False) |
| # Just waiting... |
| request.ws_stream.receive_message() |
| def web_socket_passive_closing_handshake(request): |
| - code = struct.pack('!H', 3004) |
| - packet = stream.create_close_frame(code + 'split test'.encode('utf-8')) |
| - request.connection.write(packet[:1]) |
| - request.connection.write(packet[1:]) |
| - raise handshake.AbortedByUserException('Abort the connection') |
| + global numOpenConnections |
| + global numClosedConnections |
| + numOpenConnections -= 1 |
| + numClosedConnections += 1 |
| + return (1000, '') |