Пример #1
0
        /// <summary>
        /// TCP로 패킷 배열을 보낸다.
        /// </summary>
        /// <param name="p">인터페이스 상속 패킷 클래스 배열</param>
        public void Send(IPacket[] p)
        {
            try
            {
                // 사이즈 오버헤드에 대한 예외처리 구현이 필요함.
                int           size  = 0;
                List <byte[]> dList = new List <byte[]>();
                for (int i = 0; i < p.Length; ++i)
                {
                    var d = PacketMaker.SetPacket(p[i]);
                    size += d.Length;
                    dList.Add(d);
                }
                byte[] data   = new byte[size];
                int    curIdx = 0;
                foreach (var d in dList)
                {
                    Array.Copy(d, 0, data, curIdx, d.Length);
                    curIdx += d.Length;
                }
                clientTcp.Client.BeginSend(data, 0, data.Length, SocketFlags.None, null, clientTcp.Client);

                for (int i = 0; i < p.Length; ++i)
                {
                    Console.WriteLine("[TCP] Send [{0}] : {1}, Length : {2}", clientTcp.Client.RemoteEndPoint, p[i].GetType(), dList[i].Length);
                }
                dList.Clear();
            }
            catch (Exception e)
            {
                Console.WriteLine("[TCP] Send exception : " + e.ToString());
            }
        }
Пример #2
0
 public void Send(IPacket p)
 {
     try
     {
         var d = PacketMaker.SetPacket(p);
         clientUDP.BeginSend(d, d.Length, multicastEP, null, null);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Пример #3
0
 internal void Send(IPacket p)
 {
     try
     {
         var b = PacketMaker.SetPacket(p);
         udp.BeginSend(b, b.Length, serverEP, null, udp);
     }
     catch (Exception e)
     {
         Debug.Log(e);
     }
 }
Пример #4
0
 internal void Send(IPacket p)
 {
     try
     {
         var b = PacketMaker.SetPacket(p);
         tcp.Client.BeginSend(b, 0, b.Length, SocketFlags.None, null, tcp.Client);
     }
     catch (Exception e)
     {
         Debug.Log(e);
     }
 }
Пример #5
0
 /// <summary>
 /// TCP로 패킷을 보낸다.
 /// </summary>
 /// <param name="p">인터페이스 상속 패킷 클라스</param>
 public void Send(IPacket p)
 {
     try
     {
         var data = PacketMaker.SetPacket(p);
         clientTcp.Client.BeginSend(data, 0, data.Length, SocketFlags.None, null, clientTcp.Client);
         Console.WriteLine("[TCP] Send [{0}] : {1}, Length : {2}", clientTcp.Client.RemoteEndPoint, p.GetType(), data.Length);
     }
     catch (Exception e)
     {
         Console.WriteLine("[TCP] Send exception : " + e.ToString());
     }
 }
Пример #6
0
 public static void SendPacket(IPacket p)
 {
     try
     {
         var b = PacketMaker.SetPacket(p);
         socketTcp.BeginSend(b, 0, b.Length, SocketFlags.None, null, socketTcp);
         Debug.Log("Send");
     }
     catch (Exception e)
     {
         Debug.Log(e);
     }
 }