public bool OnCreatingResponse(PacketSession session, Packet requestPacket, Packet responsePacket)
 {
     if (requestPacket.WordCount == 1)
     {
         // get the current password
         Vars vars = session.Server.Vars;
         if (vars.ContainsKey(Command))
         {
             object value = vars[Command];
             responsePacket.Words.Add(RConDevServer.Protocol.Dice.Battlefield3.Constants.RESPONSE_SUCCESS);
             responsePacket.Words.Add(Convert.ToString(value));
         }
         else
         {
             responsePacket.Words.Add(RConDevServer.Protocol.Dice.Battlefield3.Constants.RESPONSE_UNKNOWN_COMMAND);
         }
     }
     else if (requestPacket.WordCount == 2)
     {
         // set the password
     }
     else
     {
         responsePacket.Words.Add(RConDevServer.Protocol.Dice.Battlefield3.Constants.RESPONSE_INVALID_ARGUMENTS);
     }
     return true;
 }
예제 #2
0
        static IEnumerable<Path> GetValidPaths(IEnumerable<int> root, Packet packet)
        {
            if (packet is Value) yield return new Path(root);
            if (packet is List)
            {
                int index = 0;

                foreach (Packet subPacket in (List)packet)
                    foreach (Path subPath in GetValidPaths(root.Append(index++), subPacket))
                        yield return subPath;
            }
        }
 public bool OnCreatingResponse(PacketSession session, Packet requestPacket, Packet responsePacket)
 {
     if (requestPacket.WordCount == 1)
     {
         // get the server name
         Vars vars = session.Server.Vars;
         if (vars.ContainsKey(Command))
         {
             object value = vars[Command];
             responsePacket.Words.Add(RConDevServer.Protocol.Dice.Battlefield3.Constants.RESPONSE_SUCCESS);
             responsePacket.Words.Add(Convert.ToString(value));
         }
         else
         {
             responsePacket.Words.Add(RConDevServer.Protocol.Dice.Battlefield3.Constants.RESPONSE_UNKNOWN_COMMAND);
         }
     }
     else if (requestPacket.WordCount == 2)
     {
         // set server name
         string valueToSet = requestPacket.Words[1];
         if (valueToSet.Length > 240)
         {
             responsePacket.Words.Add(RConDevServer.Protocol.Dice.Battlefield3.Constants.RESPONSE_TOO_LONG_NAME);
         }
         else
         {
             session.Server.ServerInfo.ServerName = valueToSet;
             responsePacket.Words.Add(RConDevServer.Protocol.Dice.Battlefield3.Constants.RESPONSE_SUCCESS);
         }
     }
     else
     {
         responsePacket.Words.Add(RConDevServer.Protocol.Dice.Battlefield3.Constants.RESPONSE_INVALID_ARGUMENTS);
     }
     return true;
 }
예제 #4
0
 protected void Initialize()
 {
     Sample = Enumerables.Consume<Packet>(Read).First(packet => packet != null && !(packet is InvalidPacket));
 }