コード例 #1
0
 private void SiteSendRequest()
 {
     try
     {
         DisplayMessage("[Site] Requisitando ao lider o acesso ao banco de dados");
         // Initialise a packet object to store the data to be sent
         Packet sendData = new Packet();
         sendData.ReadData.Add("ChatDataIdentifier", DataIdentifier.SiteRequest);
         sendData.ReadData.Add("ChatId", myId);
         IPEndPoint client = IpData.CreateIPEndPoint("127.0.0.1:" + (InitialServerPort + leaderId).ToString());
         // Initialise the EndPoint for the client
         var    epClient = (EndPoint)client;
         byte[] byteData = sendData.GetDataStream();
         serverSocket.BeginSendTo(byteData, 0, byteData.Length, SocketFlags.None, epClient, new AsyncCallback(this.SendData), null);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Send Error: " + ex.Message, "SiteSendRequest", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
 private void SendReleaseQueue(int i)
 {
     try
     {
         DisplayMessage("[Leader] Processo " + i + " liberado para atualização");
         // Initialise a packet object to store the data to be sent
         Packet sendData = new Packet();
         sendData.ReadData.Add("ChatDataIdentifier", DataIdentifier.SiteRelease);
         sendData.ReadData.Add("ChatId", myId);
         IPEndPoint client = IpData.CreateIPEndPoint("127.0.0.1:" + (InitialServerPort + i).ToString());
         // Initialise the EndPoint for the client
         var    epClient = (EndPoint)client;
         byte[] byteData = sendData.GetDataStream();
         serverSocket.BeginSendTo(byteData, 0, byteData.Length, SocketFlags.None, epClient, new AsyncCallback(this.SendData), null);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Send Error: " + ex.Message, "SendReleaseQueue", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #3
0
 private void SiteSendUserIndex(string name, string ip, string str)
 {
     DisplayMessage("[Site] enviando a " + name + " a string [" + str + "]");
     try
     {
         // Initialise a packet object to store the data to be sent
         Packet sendData = new Packet();
         sendData.ReadData.Add("ChatDataIdentifier", (str == "" ? DataIdentifier.SiteFail : DataIdentifier.SiteOk));
         sendData.ReadData.Add("ChatMessage", str);
         sendData.ReadData.Add("ChatId", myId);
         IPEndPoint client = IpData.CreateIPEndPoint(ip);
         // Initialise the EndPoint for the client
         var    epClient = (EndPoint)client;
         byte[] byteData = sendData.GetDataStream();
         serverSocket.BeginSendTo(byteData, 0, byteData.Length, SocketFlags.None, epClient, new AsyncCallback(this.SendData), null);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Send Error: " + ex.Message, "SiteSendUserIndex", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #4
0
 private void SiteSendUpdate(string s)
 {
     try
     {
         // Initialise a packet object to store the data to be sent
         Packet sendData = new Packet();
         sendData.ReadData.Add("ChatDataIdentifier", DataIdentifier.UpdateList);
         sendData.ReadData.Add("ChatMessage", s);
         sendData.ReadData.Add("ChatId", myId);
         for (int i = 1; i <= 3; i++)
         {
             IPEndPoint client = IpData.CreateIPEndPoint("127.0.0.1:" + (InitialServerPort + i).ToString());
             // Initialise the EndPoint for the client
             var    epClient = (EndPoint)client;
             byte[] byteData = sendData.GetDataStream();
             serverSocket.BeginSendTo(byteData, 0, byteData.Length, SocketFlags.None, epClient, new AsyncCallback(this.SendData), null);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Send Error: " + ex.Message, "SendUpdate", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }