Hello, I have tried to send welcome message by editing echo handler from examples.
Unfortunately, it doesnt work. Could you explain to me what is wrong?
_GOODBYE_MESSAGE = u'Goodbye'
def web_socket_do_extra_handshake(request):
request.ws_stream.send_message("Welcome", binary=False) # Error line
pass # Always accept.
def web_socket_transfer_data(request):
while True:
line = request.ws_stream.receive_message()
if line is None:
return
if isinstance(line, unicode):
request.ws_stream.send_message("Sending", binary=False)
request.ws_stream.send_message(line, binary=False)
if line == _GOODBYE_MESSAGE:
return
else:
request.ws_stream.send_message(line, binary=True)
and this:
_GOODBYE_MESSAGE = u'Goodbye'
welcome = True
def web_socket_do_extra_handshake(request):
pass # Always accept.
def web_socket_transfer_data(request):
while True:
if welcome:
welcome = False
request.ws_stream.send_message("Welcome !", binary=False)
line = request.ws_stream.receive_message()
if line is None:
return
if isinstance(line, unicode):
request.ws_stream.send_message("Sending", binary=False)
request.ws_stream.send_message(line, binary=False)
if line == _GOODBYE_MESSAGE:
return
else:
request.ws_stream.send_message(line, binary=True)
Why none of this works (Im getting 1006 error code).