Hi,
Please take the request object inside web_socket_transfer_data and instantiate MessageSender or MessageReceiver with it as you want.
They spawn a new thread for running send_message/receive_message. You can do
- non-blocking receive by calling receiver.receive_nowait (where receiver is instantiated by onmessage=None)
- asynchronous receive by instantiating receiver by onmessage=<some method for handling received message>
- asynchronous send by sender.send_nowait.
Please make sure that you don't exit the web_socket_transfer_data function while you're serving some request since when you return from that function, pywebsocket closes the connection.
Takeshi