making WebSocketAPI to react to messages