예제 #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 + "字节");
     }
 }
예제 #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 + "字节");
     }
 }
예제 #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 + "字节");
     }
 }
예제 #4
0
 public void Send(PackHead head, byte[] data)
 {
     byte[] sendData = dataPacker.Packer(head, data);
     Send(sendData);
 }
예제 #5
0
파일: UDP.cs 프로젝트: bmjoy/MiniFramework
 public void Send(PackHead head, byte[] data, string ip, int port)
 {
     byte[] sendData = dataPacker.Packer(head, data);
     Send(sendData, ip, port);
 }