Chromium Code Reviews| Index: net/data/websocket/count-connection_wsh.py |
| diff --git a/net/data/websocket/count-connection_wsh.py b/net/data/websocket/count-connection_wsh.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e785d128c2bef0f508ca93d731762e6fb78e24b6 |
| --- /dev/null |
| +++ b/net/data/websocket/count-connection_wsh.py |
| @@ -0,0 +1,26 @@ |
| +# Copyright (c) 2014 The Chromium Authors. All rights reserved. |
|
Adam Rice
2014/07/14 12:12:14
The "(c)" isn't used any more.
yhirano
2014/07/15 01:50:03
Done.
|
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +numOpenConnections = 0 |
| +numClosedConnections = 0 |
| + |
| + |
| +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): |
| + global numOpenConnections |
| + global numClosedConnections |
| + numOpenConnections -= 1 |
| + numClosedConnections += 1 |
| + return (1000, '') |