Exemplo n.º 1
0
        public void PostSendPacket(PACKET_ID packetID, byte[] packetData)
        {
            if (Network.IsConnected() == false)
            {
                DevLog.Write("서버 연결이 되어 있지 않습니다", LOG_LEVEL.ERROR);
                return;
            }

            var header = new MsgPackPacketHeadInfo();

            header.TotalSize = (UInt16)packetData.Length;
            header.Id        = (UInt16)packetID;
            header.Type      = 0;
            header.Write(packetData);

            SendPacketQueue.Enqueue(packetData);
        }
Exemplo n.º 2
0
        void PacketProcess(byte[] packet)
        {
            var header = new MsgPackPacketHeadInfo();

            header.Read(packet);

            var packetType = (PACKET_ID)header.Id;

            //DevLog.Write("Packet Error:  PacketID:{packet.PacketID.ToString()},  Error: {(ERROR_CODE)packet.Result}");
            //DevLog.Write("RawPacket: " + packet.PacketID.ToString() + ", " + PacketDump.Bytes(packet.BodyData));

            if (PacketFuncDic.ContainsKey(packetType))
            {
                PacketFuncDic[packetType](packet);
            }
            else
            {
                DevLog.Write("Unknown Packet Id: " + packetType);
            }
        }
Exemplo n.º 3
0
        public byte[] Read()
        {
            var enableReadSize = WritePos - ReadPos;

            if (enableReadSize < HeaderSize)
            {
                return(null);
            }

            var packetDataSize = MsgPackPacketHeadInfo.GetTotalSize(PacketData, ReadPos);

            if (enableReadSize < packetDataSize)
            {
                return(null);
            }

            var packet = new byte[packetDataSize];

            Buffer.BlockCopy(PacketData, ReadPos, packet, 0, packetDataSize);

            ReadPos += packetDataSize;

            return(packet);
        }