added threading in WebSocketEndpoint