I'm trying to implement my own websocket server and am running into a bit of trouble with the onmessage function in the JavaScript. It just won't fire! I put an alert into it to trigger whenever it was called and the alert never comes up. I've tried on both firefox and chrome to no avail.
As far as I can tell, my server is sending the correct message as well, when I translate it into hex, it matches perfectly with the example in section 5.7 of the documentation here:
http://datatracker.ietf.org/doc/rfc6455/?include_text=1
So I'm not entirely sure what I'm doing wrong. The handshake works fine and so does the close. Here is my code for sending a message currently:
formatted_bytes = []
formatted_bytes.append( 129 )
message_bytes = bytearray( message )
data_start = 0
if ( len( message_bytes ) <= 125 ):
formatted_bytes.append( len( message_bytes ) )
start = 2
for byte in message_bytes:
formatted_bytes.append( byte )
client_socket.send( bytes( formatted_bytes ) )
The server is written in python, forgot to mention that.