public Boolean SendPacket(OutPacket oPacket)
 {
     try
     {
         if (_socket.Connected)
         {
             // packet을 보낸다.
             NetworkStream stream = _socket.GetStream();
             Byte[] data = oPacket.BufBytes.ToArray();
             stream.BeginWrite(data, 0, data.Length, TcpStreamManager.WriteCallBack, this);
             return true;
         }
         else
         {
             logger.Warn("socket is closed.");
             return false;
         }
     }
     catch (System.Exception ex)
     {
         logger.Error(ex.ToString());
         ProcessUtil.Kill();
     }
     return false;
 }
Beispiel #2
0
        public void OutPacketEncodeTest()
        {
            OutPacket target = new OutPacket();
            target.ReserveForPacketLength(6, 6);
            target.Encode32(100, 10);
            target.EncodeStr("test", 10);

            target.BuildPacketWithPacketLength();

            InPacket iPacket = new InPacket(target);

            String strPacket = iPacket.ToString();

            int result = strPacket.CompareTo("20    100       test      ");

            Assert.AreEqual(0, result);
        }
Beispiel #3
0
 public Boolean SendPacket(OutPacket oPacket, long packetID, KBHTS kbhts)
 {
     lock (locker)
     {
         _map.Add(packetID, kbhts);
         return TossClientSession.Ins().SendPacket(oPacket);
     }
 }
Beispiel #4
0
 public InPacket(OutPacket oPacket)
 {
     List<Byte> aBuf = oPacket.BufBytes;
     _aBuf_Bytes.AddRange(aBuf);
 }