public string Stringify() { StringBuilder sb = new StringBuilder(); sb.Append("{\"Type\":\"" + Type + "\","); sb.Append("\"Message\":"); if (Message is IJson) { sb.Append(((IJson)Message).Stringify() + "}"); return(sb.ToString()); } sb.Append(JsonConvertor.ToJSON(Message) + "}"); return(sb.ToString()); }
private void BroadCast(IClient client, Packet packet) { byte[] buffer; try { buffer = Encoding.UTF8.GetBytes(JsonConvertor.ToJSON(packet)); if (buffer == null || buffer.Length == 0) { return; } } catch (Exception ex) { DebugLogger.AddLog("Exception:" + ex); return; } foreach (IClient c in Clients) { if (c != client && c.IsConnected) { c.Write(buffer); } } }