Exemplo n.º 1
0
        private void ParseServerMessage()
        {
#if DEBUG_PROXY
            Trace.WriteLine("[DEBUG] Proxy [ParseServerMessage]");
#endif
            switch (protocol)
            {
            case Protocol.None:

                clientOutMessage.Reset();
                Array.Copy(serverInMessage.Buffer, clientOutMessage.Buffer, serverInMessage.Size);
                clientOutMessage.Size = serverInMessage.Size;
                SendToClient(clientOutMessage);

                break;

            case Protocol.Login:
                ParseServerLoginMessage();
                break;

            case Protocol.World:
                ParseServerWorldMessage();
                break;
            }
        }
Exemplo n.º 2
0
        private void ParseClientWorldMessage()
        {
#if DEBUG_PROXY
            Trace.WriteLine("[DEBUG] Proxy [ParseClientWorldMessage]");
#endif
            serverOutMessage.Reset();
            Array.Copy(clientInMessage.Buffer, serverOutMessage.Buffer, clientInMessage.Size);
            serverOutMessage.Size = clientInMessage.Size;

            clientInMessage.ReadPosition = 2;

            if (Adler.Generate(clientInMessage) != clientInMessage.ReadChecksum())
            {
                throw new Exception("Wrong checksum.");
            }

            Xtea.Decrypt(clientInMessage, xteaKey);
            clientInMessage.Size         = clientInMessage.ReadInternalHead() + 8;
            clientInMessage.ReadPosition = 8;

            client.ProtocolWorld.ParseClientMessage(clientInMessage);

            SendToServer(serverOutMessage);
        }