Added onmessage handler for the websocket.