Example #1
0
 private void OnCommandReceived()
 {
     char[]   separator = new char[] { ' ' };
     string[] strArray  = ConnectAPI.GetDebugConsoleCommand().Split(separator);
     if (strArray.Length == 0)
     {
         Log.Rachelle.Print("Received empty command from debug console!", new object[0]);
     }
     else
     {
         string        key           = strArray[0];
         List <string> commandParams = new List <string>();
         for (int i = 1; i < strArray.Length; i++)
         {
             commandParams.Add(strArray[i]);
         }
         if (s_serverConsoleCallbackMap.ContainsKey(key))
         {
             this.SendConsoleCmdToServer(key, commandParams);
         }
         else if (!s_clientConsoleCallbackMap.ContainsKey(key))
         {
             this.SendDebugConsoleResponse(DebugConsoleResponseType.CONSOLE_OUTPUT, string.Format("Unknown command '{0}'.", key));
         }
         else
         {
             ConsoleCallbackInfo info = s_clientConsoleCallbackMap[key];
             if (info.GetNumParams() != commandParams.Count)
             {
                 this.SendDebugConsoleResponse(DebugConsoleResponseType.CONSOLE_OUTPUT, string.Format("Invalid params for command '{0}'.", key));
             }
             else
             {
                 Log.Rachelle.Print(string.Format("Processing command '{0}' from debug console.", key), new object[0]);
                 info.Callback(commandParams);
             }
         }
     }
 }