예제 #1
0
        public byte[] Compile()
        {
            if (_Buffer != null)
            {
                return(_Buffer);
            }

            if (Stream == null)
            {
                Console.WriteLine("{0}: {1}: Bad Packet: Stream is null", GetType().Name, ID);

                return(_Buffer = _EmptyBuffer);
            }

            using (Stream)
            {
                Stream.Position = MinSize - 4;
                Stream.Write(Stream.Length);
                Stream.Position = Stream.Length;

                if (_Buffer == null)
                {
                    _Buffer = Stream.ToArray();
                }

                Stream.Close();
                Stream = null;
            }

            return(_Buffer);
        }
예제 #2
0
        protected PortalPacket(ushort packetID, int size)
        {
            ID = packetID;

            ClientID = Portal.ClientID;

            _Stream = new PortalPacketWriter(ID, ClientID, size);
        }
예제 #3
0
        protected PortalPacket(ushort packetID)
        {
            ClientID = Portal.ClientID;

            ID = packetID;

            Stream = new PortalPacketWriter(ID, ClientID);
        }
예제 #4
0
        protected PortalPacket(ushort packetID)
        {
            ClientID = Portal.ClientID;

            ID = packetID;

            Stream = new PortalPacketWriter(ID, ClientID);
        }
예제 #5
0
        protected PortalPacket(byte packetID, ushort length)
        {
            ClientID = Portal.ClientID;

            ID     = packetID;
            Length = length;

            Stream = new PortalPacketWriter(ID, ClientID, Length);
        }
예제 #6
0
        protected PortalPacket(byte packetID, ushort length)
        {
            ClientID = Portal.ClientID;

            ID = packetID;
            Length = length;

            Stream = new PortalPacketWriter(ID, ClientID, Length);
        }
예제 #7
0
 public void Dispose()
 {
     lock (_SyncRoot)
     {
         if (_Stream != null)
         {
             _Stream.Dispose();
             _Stream = null;
         }
     }
 }
예제 #8
0
        public byte[] Compile()
        {
            if (_Buffer != null)
            {
                return(_Buffer);
            }

            if (Stream == null)
            {
                Console.WriteLine("{0}: {1}: Bad Packet: Stream is null", GetType().Name, ID);

                return(_Buffer = _EmptyBuffer);
            }

            using (Stream)
            {
                if (Length == 0)
                {
                    Stream.Position = 3;
                    Stream.Write(Stream.Length);
                }
                else if (Stream.Length != Length)
                {
                    var diff = Stream.Length - Length;

                    Console.WriteLine(
                        "{0}: {1}: Bad Packet Length: {2}{3} bytes",
                        GetType().Name,
                        ID,
                        diff > 0 ? "+" : String.Empty,
                        diff);

                    _Buffer = _EmptyBuffer;
                }

                if (_Buffer == null)
                {
                    _Buffer = Stream.ToArray();
                }

                Stream.Close();
                Stream = null;
            }

            return(_Buffer);
        }
예제 #9
0
        public byte[] Compile()
        {
            if (_Buffer != null)
            {
                return _Buffer;
            }

            if (Stream == null)
            {
                Console.WriteLine("{0}: {1}: Bad Packet: Stream is null", GetType().Name, ID);

                return _Buffer = _EmptyBuffer;
            }

            using (Stream)
            {
                Stream.Position = MinSize - 4;
                Stream.Write(Stream.Length);
                Stream.Position = Stream.Length;

                if (_Buffer == null)
                {
                    _Buffer = Stream.ToArray();
                }

                Stream.Close();
                Stream = null;
            }

            return _Buffer;
        }
예제 #10
0
        public byte[] Compile()
        {
            if (_Buffer != null)
            {
                return _Buffer;
            }

            if (Stream == null)
            {
                Console.WriteLine("{0}: {1}: Bad Packet: Stream is null", GetType().Name, ID);

                return _Buffer = _EmptyBuffer;
            }

            using (Stream)
            {
                if (Length == 0)
                {
                    Stream.Position = 3;
                    Stream.Write(Stream.Length);
                }
                else if (Stream.Length != Length)
                {
                    var diff = Stream.Length - Length;

                    Console.WriteLine(
                        "{0}: {1}: Bad Packet Length: {2}{3} bytes",
                        GetType().Name,
                        ID,
                        diff > 0 ? "+" : String.Empty,
                        diff);

                    _Buffer = _EmptyBuffer;
                }

                if (_Buffer == null)
                {
                    _Buffer = Stream.ToArray();
                }

                Stream.Close();
                Stream = null;
            }

            return _Buffer;
        }