protected override void OnMessage(MessageEventArgs e) { MemoryStream stream = new MemoryStream(e.RawData); WebSocketMessage deserialized = null; try { deserialized = (WebSocketMessage)EvosSerializer.Instance.Deserialize(stream); } catch (NullReferenceException nullEx) { Log.Print(LogType.Error, "No message handler registered for data:\n" + BitConverter.ToString(e.RawData)); } if (deserialized != null) { EvosMessageDelegate <WebSocketMessage> handler = GetHandler(deserialized.GetType()); if (handler != null) { Log.Print(LogType.Network, "Received " + deserialized.GetType().Name); handler.Invoke(deserialized); } else { Log.Print(LogType.Error, "No handler for " + deserialized.GetType().Name + "\n" + Newtonsoft.Json.JsonConvert.SerializeObject(deserialized, Newtonsoft.Json.Formatting.Indented)); } } }