void m_WebSocket_MessageReceived(object sender, MessageReceivedEventArgs e) { if (string.IsNullOrEmpty(e.Message)) { return; } int pos = e.Message.IndexOf(' '); string name; string parameter; string token = string.Empty; if (pos > 0) { name = e.Message.Substring(0, pos); parameter = e.Message.Substring(pos + 1); pos = name.IndexOf('-'); if (pos > 0) { token = name.Substring(pos + 1); name = name.Substring(0, pos); } } else { name = e.Message; parameter = string.Empty; } IJsonExecutor executor = GetExecutor(name, token); if (executor != null) { if (!executor.Type.IsPrimitive) { executor.Execute(this, token, DeserializeObject(parameter, executor.Type)); } else { executor.Execute(this, token, Convert.ChangeType(parameter, executor.Type, null)); } } }
private void m_WebSocket_MessageReceived(object sender, MessageReceivedEventArgs e) { if (string.IsNullOrEmpty(e.Message)) { return; } int length1 = e.Message.IndexOf(' '); string token = string.Empty; string name; string json; if (length1 > 0) { name = e.Message.Substring(0, length1); json = e.Message.Substring(length1 + 1); int length2 = name.IndexOf('-'); if (length2 > 0) { token = name.Substring(length2 + 1); name = name.Substring(0, length2); } } else { name = e.Message; json = string.Empty; } IJsonExecutor executor = this.GetExecutor(name, token); if (executor == null) { return; } object obj; try { obj = executor.Type.IsSimpleType() ? ((object)json.GetType() != (object)executor.Type ? Convert.ChangeType((object)json, executor.Type, (IFormatProvider)null) : (object)json) : this.DeserializeObject(json, executor.Type); } catch (Exception ex) { this.m_WebSocket_Error((object)this, new ErrorEventArgs(new Exception("DeserializeObject exception", ex))); return; } try { executor.Execute(this, token, obj); } catch (Exception ex) { this.m_WebSocket_Error((object)this, new ErrorEventArgs(new Exception("Message handling exception", ex))); } }
void m_WebSocket_MessageReceived(object sender, MessageReceivedEventArgs e) { if (string.IsNullOrEmpty(e.Message)) { return; } int pos = e.Message.IndexOf(' '); string name; string parameter; string token = string.Empty; if (pos > 0) { name = e.Message.Substring(0, pos); parameter = e.Message.Substring(pos + 1); pos = name.IndexOf('-'); if (pos > 0) { token = name.Substring(pos + 1); name = name.Substring(0, pos); } } else { name = e.Message; parameter = string.Empty; } IJsonExecutor executor = GetExecutor(name, token); if (executor == null) { return; } object value; try { if (!executor.Type.IsPrimitive) { value = DeserializeObject(parameter, executor.Type); } else { value = Convert.ChangeType(parameter, executor.Type, null); } } catch (Exception exc) { m_WebSocket_Error(this, new ErrorEventArgs(new Exception("DeserializeObject exception", exc))); return; } try { executor.Execute(this, token, value); } catch (Exception exce) { m_WebSocket_Error(this, new ErrorEventArgs(new Exception("Message handling exception", exce))); } }