1# Copyright 2023 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import six 6import time 7 8 9def web_socket_do_extra_handshake(request): 10 request.ws_extension_processors = [] 11 12 13def web_socket_transfer_data(request): 14 while True: 15 message = request.ws_stream.receive_message() 16 17 if message is None: 18 return 19 20 # Send <message> count messages to the web socket, each a quarter second 21 # apart. 22 for i in range(int(message)): 23 request.ws_stream.send_message('ping', binary=False) 24 time.sleep(0.25) 25