Beispiel #1
0
        public async Task <bool> ExecuteCommand(StaticCommand staticCommand, TransmissionEvent transmissionEvent,
                                                ExecutionEvent executionEvent, StopEvent stopEvent, List <Condition> conditions, CommandTarget target)
        {
            if (conditions != null && conditions.Count == 0)
            {
                conditions = null;
            }

            var plugin = StaticCommands[staticCommand.GetType()];

            if (plugin != null)
            {
                if (!await UploadPluginToServer(plugin))
                {
                    return(false);
                }
            }

            _connectionManager.SendCommand(new DynamicCommand
            {
                CommandId         = staticCommand.CommandId,
                Target            = target,
                Conditions        = conditions,
                TransmissionEvent = transmissionEvent,
                ExecutionEvent    = executionEvent,
                CommandParameter  = staticCommand.GetCommandParameter().Data,
                PluginHash        = plugin?.PluginHash,
                StopEvent         = stopEvent
            });

            return(true);
        }
Beispiel #2
0
        public void SendCommand(StaticCommand staticCommand)
        {
            var parameter = staticCommand.GetCommandParameter().Data;

            ConnectionInfo.UnsafeSendCommand(this, parameter.Length + 17, writer =>
            {
                writer.Write((byte)ClientCommandsCommunication.SendCommand);
                writer.Write(staticCommand.CommandId.ToByteArray());
                writer.Write(parameter);
            });
            LogService.Send(string.Format((string)Application.Current.Resources["ExecuteStaticCommand"],
                                          staticCommand.Name));
        }
        public void ExecuteCommand(StaticCommand staticCommand, TransmissionEvent transmissionEvent, ExecutionEvent executionEvent,
                                   List <Condition> conditions, CommandTarget target)
        {
            if (conditions != null && conditions.Count == 0)
            {
                conditions = null;
            }

            _serverConnection.SendCommand(new DynamicCommand
            {
                CommandId         = staticCommand.CommandId,
                Target            = target,
                Conditions        = conditions,
                TransmissionEvent = transmissionEvent,
                ExecutionEvent    = executionEvent,
                CommandParameter  = staticCommand.GetCommandParameter().Data,
                PluginHash        = null
            });
        }