echo_exit_wsh.py (521B)
1 #!/usr/bin/python 2 3 _GOODBYE_MESSAGE = u'Goodbye' 4 5 def web_socket_do_extra_handshake(request): 6 # This example handler accepts any request. See origin_check_wsh.py for how 7 # to reject access from untrusted scripts based on origin value. 8 9 pass # Always accept. 10 11 12 def web_socket_transfer_data(request): 13 while True: 14 line = request.ws_stream.receive_message() 15 if line is None: 16 return 17 if isinstance(line, str): 18 if line == _GOODBYE_MESSAGE: 19 return