예제 #1
0
 public void Send(string clientName, string message)
 {
     DataRow[] rowArray = this.clientSet.Tables["Client"].Select(string.Format("Name='{0}'", clientName));
     if (rowArray.Length != 0)
     {
         DataRow row = rowArray[0];
         Client client = new Client(row["IP"].ToString(), Convert.ToInt32(row["Port"]));
         client.Send(message);
         client.Release();
     }
     else if (this.OnReceive != null)
     {
         MessageParser parser = new MessageParser();
         this.OnReceive(this, parser.Parse(message));
     }
 }
예제 #2
0
 private void server_OnReceive(object sender, ReceiveEventArgs e)
 {
     try
     {
         Message message = new MessageParser().Parse(e.Message);
         List<string> receivers = message.Receivers;
         for (int i = 0; i < receivers.Count; i++)
         {
             string clientName = receivers[i].ToString();
             if (clientName.ToUpper() == this.name.ToUpper())
             {
                 this.ProcessMessage(message);
             }
             else
             {
                 this.Send(clientName, message.Msg);
             }
         }
     }
     catch
     {
     }
 }