Example #1
0
            public void HandleData(Packet p)
            {
                int packetLength = p.ReadInt();

                byte[] packetBytes = p.ReadBytes(packetLength);

                ThreadManager.ExecuteOnMainThread(() =>
                {
                    using (Packet p = new Packet(packetBytes))
                    {
                        int packetId = p.ReadInt();
                        Server.packetHandlers[packetId](id, p);
                    }
                });
            }
        public void HandleData(Packet _packetData)
        {
            int _packetLength = _packetData.ReadInt();

            byte[] _packetBytes = _packetData.ReadBytes(_packetLength);

            ThreadManager.ExecuteOnMainThread(() =>
            {
                using (Packet _packet = new Packet(_packetBytes))
                {
                    int _packetId = _packet.ReadInt();
                    Server.packetHandlers[_packetId](id, _packet);
                }
            });
        }
Example #3
0
        public void HandleData(Packet packetData)
        {
            int packetLength = packetData.ReadInt();

            byte[] packetBytes = packetData.ReadBytes(packetLength);


            ThreadManager.ExecuteOnMainThread(() =>
            {
                using (Packet packet = new Packet(packetBytes))
                {
                    int packetID = packet.ReadInt();
                    Server.packetHandlers[packetID](clientID, packet);
                }
            });
        }
Example #4
0
        private bool HandleData(byte[] data)
        {
            int packetLength = 0;

            receiveData.SetBytes(data);

            if (receiveData.UnreadLength() >= 4)
            {
                packetLength = receiveData.ReadInt();
                if (packetLength <= 0)
                {
                    return(true);
                }
            }

            while (packetLength > 0 && packetLength <= receiveData.UnreadLength())
            {
                byte[] packetBytes = receiveData.ReadBytes(packetLength);

                ThreadManager.ExecuteOnMainThread(() =>
                {
                    using (Packet packet = new Packet(packetBytes))
                    {
                        int packetID = packet.ReadInt();
                        Server.packetHandlers[packetID](id, packet);
                    }
                });

                packetLength = 0;

                if (receiveData.UnreadLength() >= 4)
                {
                    packetLength = receiveData.ReadInt();
                    if (packetLength <= 0)
                    {
                        return(true);
                    }
                }
            }

            if (packetLength <= 1)
            {
                return(true);
            }
            return(false);
        }
Example #5
0
            /// <summary>Prepares received data to be used by the appropriate packet handler methods.</summary>
            /// <param name="data">The recieved data.</param>
            private static void HandleData(byte[] data)
            {
                using (Packet packet = new Packet(data))
                {
                    int packetLength = packet.ReadInt();
                    data = packet.ReadBytes(packetLength);
                }

                ThreadManager.ExecuteOnMainThread(() =>
                {
                    using (Packet packet = new Packet(data))
                    {
                        int packetId = packet.ReadInt();
                        packetHandlers[packetId](packet); // Call appropriate method to handle the packet
                    }
                });
            }
Example #6
0
        private bool HandleData(byte[] _data)
        {
            int _packetLength = 0;

            receivedData.SetBytes(_data);

            if (receivedData.UnreadLength() >= 4)
            {
                _packetLength = receivedData.ReadInt();
                if (_packetLength <= 0)
                {
                    return(true);
                }
            }

            while (_packetLength > 0 && _packetLength <= receivedData.UnreadLength())
            {
                byte[] _packetBytes = receivedData.ReadBytes(_packetLength);
                ThreadManager.ExecuteOnMainThread(() =>
                {
                    using (Packet _packet = new Packet(_packetBytes))
                    {
                        int _packetId = _packet.ReadInt();
                        Server.packetHandlers[_packetId](id, _packet);
                    }
                });

                _packetLength = 0;
                if (receivedData.UnreadLength() >= 4)
                {
                    _packetLength = receivedData.ReadInt();
                    if (_packetLength <= 0)
                    {
                        return(true);
                    }
                }
            }

            if (_packetLength <= 1)
            {
                return(true);
            }

            return(false);
        }
Example #7
0
            private bool handleData(byte[] data)
            {
                int pLenght = 0;

                recievedData.SetBytes(data);
                if (recievedData.UnreadLength() >= 4)
                {
                    pLenght = recievedData.ReadInt();
                    if (pLenght <= 0)
                    {
                        return(true);
                    }
                }
                while (pLenght > 0 && pLenght <= recievedData.UnreadLength())
                {
                    byte[] pBytes = recievedData.ReadBytes(pLenght);
                    ThreadManager.ExecuteOnMainThread(() => {
                        using (Packet P = new Packet(pBytes)) {
                            int PID = P.ReadInt();
                            Server.Managers[PID](id, P);
                        }
                    });
                    pLenght = 0;
                    if (recievedData.UnreadLength() >= 4)
                    {
                        pLenght = recievedData.ReadInt();
                        if (pLenght <= 0)
                        {
                            return(true);
                        }
                    }
                }
                if (pLenght <= 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }