protected override Task OnMessageReceivedAsync(IWebSocketContext context, byte[] buffer, IWebSocketReceiveResult result) { return(Dispatcher.DoAction(() => { CommContext commContext; if (!mContextMap.TryGetValue(context, out commContext)) { commContext = null; } if (commContext != null) { string json = Encoding.UTF8.GetString(buffer); int index = json.IndexOf(":"); if (index > 0) { string type = json.Substring(0, index); json = json.Substring(index + 1); Type t; if (BaseServer.MessageNameToType.TryGetValue(type, out t)) { CommMessage message = Json.Deserialize(json, t) as CommMessage; if (message != null) { message.Handle(commContext); } } } } })); }