Exemple #1
0
        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());
        }
Exemple #2
0
 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);
         }
     }
 }