Пример #1
0
        private void postProcessUniversalPacket(ClientWorkObject workObject, IUniversalPacket universalPacket)
        {
            UniversalPacket clientPacket = (UniversalPacket)universalPacket;

            //Checks if the user ID is registered (IsLoggedIn)
            //If the ID is not stored then stores the ID and
            //the IP of the client for logging reasons.
            if (!workObject.clientTracker.IsLoggedIn)
            {
                workObject.clientTracker.SetID(clientPacket.MessageSignature.clientId,
                                               ((IPEndPoint)workObject.clientSocket.RemoteEndPoint).Address.ToString(),
                                               clientPacket.MessageSignature.clientIp);
            }
            clientPacket.MessageHeader.dateTime = DateTime.Now; //Sets the datetime if its null
            string s = workObject.Encryption.GetServerPrivateKey();

            //Decrypts the information
            if (clientPacket.MessageData.IsEncrypted)
            {
                clientPacket.MessageData.Data = workObject.Encryption.Decrypt(clientPacket.MessageData.Data, workObject.Encryption.GetServerPrivateKey());
            }

            OnBeforeClientRequestEventArgs onBeforeRequest = new OnBeforeClientRequestEventArgs {
                RawData = clientPacket.MessageData.Data, Client = workObject
            };

            parent.GetEventTracker().OnBeforeClientRequest(this, onBeforeRequest);

            //Processes the command
            bool sentClientData = false;

            if (onBeforeRequest.CancelRequest == Model.Utility.MoonbyteCancelRequest.Continue)
            {
                using (CommandManager commandManager = new CommandManager(parent))
                {
                    sentClientData = commandManager.ProcessUniversalPacketCommand(clientPacket, workObject, workObject.serverSocket);
                }
            }
            else
            {
                workObject.serverSocket.Send(workObject, "Unauthorized", false);
            }

            //Sends data to client if false
            if (!sentClientData)
            {
                workObject.serverSocket.Send(workObject, "UnknownCommand", false);
            }
        }
Пример #2
0
 private void postProcessUniversalPacket(ClientWorkObject workObject, IUniversalPacket universalPacket)
 {
     if (universalPacket.GetType() == typeof(UniversalGetPacket))
     {
         UniversalGetPacket packet = (UniversalGetPacket)universalPacket;
         packet.ToString();
     }
     else if (universalPacket.GetType() == typeof(UniversalPacket))
     {
         UniversalPacket packet = (UniversalPacket)universalPacket;
     }
     else
     {
         //returns error
     }
 }