1 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 numOpenConnections = 0 6 numClosedConnections = 0 7 8 9 def web_socket_do_extra_handshake(request): 10 global numOpenConnections 11 numOpenConnections += 1 12 13 14 def web_socket_transfer_data(request): 15 request.ws_stream.send_message('open: %d, closed: %d' % 16 (numOpenConnections, numClosedConnections), binary=False) 17 # Just waiting... 18 request.ws_stream.receive_message() 19 20 21 def web_socket_passive_closing_handshake(request): 22 global numOpenConnections 23 global numClosedConnections 24 numOpenConnections -= 1 25 numClosedConnections += 1 26 return (1000, '') 27