private void ExecRconCommand(CommandExecContext context) { // new cmd() var cmdInstance = this.Container.ResolveNamed<IRConCommand>(context.CommandString); cmdInstance.Metadata = this.BNetCommandsMetadata[context.CommandString]; cmdInstance.Context = context; // covariance FTW var instanceWithResults = cmdInstance as IRConCommand<object>; if (instanceWithResults != null) { // use covariance to get the generic version's virtual table instanceWithResults.ExecSingleAwaitResponse(); } else { cmdInstance.ExecuteSingle(); } // ~cmd() }
private void ExecuteCommand(CommandExecContext context) { try { if (this.BNetCommandsMetadata.ContainsKey(context.CommandString)) { this.ExecRconCommand(context); } else { this.ExecCustomCmd(context); } } catch (RConException e) { this.Log.Error("ERROR executing command '" + context.CommandString + "'.", e); } }
private void ExecCustomCmd(CommandExecContext commandCtx) { string command = commandCtx.CommandString; var beClient = new BattlEyeClient(commandCtx.Server.LoginCredentials) { ReconnectOnPacketLoss = true, DiscardConsoleMessages = true }; beClient.DisconnectEvent += this.Disconnected; beClient.Connect(); this.Log.Info("> " + command); BattlEyeCommandResult result = beClient.SendCommandPacket(command, false); this.Log.Info(result.ToString()); while (beClient.CommandQueue > 0) { /* wait until server received all packets */ } beClient.Disconnect(); // ~beClient(); }