Added private WebSocketMessage class and removed try/catch block for GetMessageType()
attached onError handler to socket error event as well so when a connection fails unexpectedly it can also be handled.