Esempio n. 1
0
 public void Broadcast(int msgID, byte[] data)
 {
     if (IsActive)
     {
         byte[]     sendData = dataPacker.Packer(msgID, data);
         IPEndPoint remoteEP = new IPEndPoint(IPAddress.Broadcast, port);
         socket.BeginSend(sendData, sendData.Length, remoteEP, SendResult, socket);
         Debug.Log("广播消息ID:" + msgID + " 大小:" + sendData.Length + "字节");
     }
 }
Esempio n. 2
0
 public void Send(int msgID, byte[] data)
 {
     if (socket != null && socket.Connected)
     {
         byte[] sendData = dataPacker.Packer(msgID, data);
         socket.GetStream().BeginWrite(sendData, 0, sendData.Length, SendResult, socket);
         Debug.Log("发送消息ID:" + msgID + " 大小:" + sendData.Length + "字节");
     }
 }
Esempio n. 3
0
 public void Send(int msgID, byte[] bodyData)
 {
     if (IsActive)
     {
         byte[] sendData = dataPacker.Packer(msgID, bodyData);
         for (int i = 0; i < remoteClients.Count; i++)
         {
             System.Net.Sockets.TcpClient client = remoteClients[i];
             if (client.Connected)
             {
                 client.GetStream().BeginWrite(sendData, 0, sendData.Length, SendResult, client);
             }
         }
         Debug.Log("发送消息ID:" + msgID + " 大小:" + sendData.Length + "字节");
     }
 }
Esempio n. 4
0
 public void Send(PackHead head, byte[] data)
 {
     byte[] sendData = dataPacker.Packer(head, data);
     Send(sendData);
 }
Esempio n. 5
0
 public void Send(PackHead head, byte[] data, string ip, int port)
 {
     byte[] sendData = dataPacker.Packer(head, data);
     Send(sendData, ip, port);
 }