Example #1
0
        public ServiceCommandOutput <object> ExecuteCommand(ClientCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            if (command.IsValid() == false)
            {
                throw new InvalidDataException("One or more mandatory values missing for command: " + command.Command);
            }

            var dictionary = command.GetAttributeDictionary <JsonPropertyAttribute>("PropertyName");
            var builder    = new StringBuilder();

            builder.Append(dictionary["command"]);
            foreach (var key in dictionary.Keys)
            {
                if (key == "command")
                {
                    continue;
                }
                if (dictionary[key] == null)
                {
                    continue;
                }

                builder.AppendFormat(@" /{0}:{1}", key, dictionary[key]);
            }

            return(ExecuteCommand(builder.ToString()));
        }
Example #2
0
        public GameActCommands(ControlSettings controlSettings, HashSet <Keys> pressedKeys)
        {
            Systems = HorizontalMove = VerticalMove = ClientCommand.Idle;
            if (controlSettings == null || pressedKeys == null)
            {
                return;
            }
            foreach (var key in pressedKeys)
            {
                if (controlSettings.ControlMap.TryGetValue(key, out var command))
                {
                    switch (command)
                    {
                    case ClientCommand.OpenFire:
                    case ClientCommand.ActivateShield:
                        Systems = command;
                        break;

                    case ClientCommand.MoveRight:
                    case ClientCommand.MoveLeft:
                        HorizontalMove = command;
                        break;

                    case ClientCommand.MoveUp:
                    case ClientCommand.MoveDown:
                        VerticalMove = command;
                        break;

                    default:
                        throw new ArgumentException($"Unknown command {command}");
                    }
                }
            }
        }
Example #3
0
        private void Accept()
        {
            ClientCommand command = new ClientCommand(ClientCommand.CommandType.AcceptTrade);

            RpgClientConnection.Instance.AddClientCommand(command);
            this.TradeRequest.TradeOffer1.Accepted = true;
        }
Example #4
0
        private static object FormatToolTip(ClientCommand command, string toolTip, CommandToolTipStyle toolTipStyle)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            if (toolTipStyle == CommandToolTipStyle.None || string.IsNullOrEmpty(toolTip))
            {
                return(null);
            }

            if (toolTipStyle != CommandToolTipStyle.AlwaysWithKeyGesture &&
                toolTipStyle != CommandToolTipStyle.EnabledWithKeyGesture)
            {
                return(toolTip);
            }

            if (command.UICommand.InputGestures.Count > 0)
            {
                KeyGesture keyGesture = command.UICommand.InputGestures[0] as KeyGesture;
                if (keyGesture != null && keyGesture.DisplayString.Length > 0)
                {
                    toolTip = string.Format(ToolTipKeyGestureFormat, toolTip, keyGesture.DisplayString);
                }
            }

            return(toolTip);
        }
Example #5
0
        /// <summary>
        /// 为一个运行时的 Command 生成 TextBox 控件。
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        protected static TextBox CreateTextBox(ClientCommand command)
        {
            var textBox = new TipTextBox()
            {
                Width             = 150,
                VerticalAlignment = VerticalAlignment.Center,
                Margin            = new Thickness(2),
                EmptyValue        = command.Label,
                ToolTip           = command.Meta.ToolTip.Translate()
            };

            //当TextBox的值改变时,通知命令进行新的输入值
            textBox.TextChanged += (o, e) =>
            {
                var txt = textBox.Text;
                if (txt == textBox.EmptyValue)
                {
                    txt = string.Empty;
                }
                SetTextBoxParameter(command, txt);
            };

            //支持UI Test
            AutomationProperties.SetName(textBox, command.Label);

            return(textBox);
        }
Example #6
0
 protected override void OnActive(ISession session)
 {
     AppendLine($"{session} 用户上线");
     _session = session;
     ClientCommand.RaiseCanExecuteChanged();
     base.OnActive(session);
 }
Example #7
0
        /// <summary>
        /// When we received data from one of our players.
        /// </summary>
        public void OnDataReceived(NetIncomingMessage message)
        {
            ClientCommand command = (ClientCommand)message.ReadByte();

            switch (command)
            {
            case ClientCommand.ActionPackage:
                OnActionPackage(message);
                break;

            case ClientCommand.StartGame:
                try {
                    ChampionTypes champ = (ChampionTypes)message.ReadUInt32();
                    AddClient(message.SenderConnection, champ);
                } catch (Exception e) {
                    ILogger.Log("Start game packet badly formatted: " + e.ToString(), LogPriority.Error);
                }
                break;

            default:
                Debug.Fail("Invalid client command.");
                ILogger.Log("Invalid client command received: " + command, LogPriority.Warning);
                break;
            }
        }
Example #8
0
        public override void OnKeyDown(OpenTK.Input.KeyboardKeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.Key == Key.Escape)
            {
                StateWindow.Instance.PopState();
                this.Destroy();
                return;
            }
            else if (e.Key == OpenTK.Input.Key.Enter && e.Alt)
            {
                Renderer.SetFulscreen(Renderer.GetFulscreen() ? false : true);
            }
            else
            {
                if (e.Key == Key.Space)
                {
                    ClientCommand command = new ClientCommand(ClientCommand.CommandType.ActionTrigger);
                    RpgClientConnection.Instance.AddClientCommand(command);
                }
                else if (e.Key == Key.Enter)
                {
                    RpgClientConnection.Instance.CloseMessageBox();
                }
                else if (e.Key == Key.LShift)
                {
                    ClientCommand command = new ClientCommand(ClientCommand.CommandType.ToggleRunning);
                    command.SetParameter("Running", true);
                    RpgClientConnection.Instance.AddClientCommand(command);
                }
            }
        }
        public async Task <IActionResult> PutClientCommand(int id, ClientCommand clientCommand)
        {
            if (id != clientCommand.Id)
            {
                return(BadRequest());
            }

            _context.Entry(clientCommand).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClientCommandExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <ClientCommand> > PostClientCommand(ClientCommand clientCommand)
        {
            _context.ClientCommands.Add(clientCommand);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetClientCommand", new { id = clientCommand.Id }, clientCommand));
        }
    /**
     * <summary>
     * Send a move command to the server
     * </summary>
     *
     * <param name="direction"></param>
     * <param name="speed"></param>
     *
     * <returns>
     * void
     * </returns>
     */
    private void SendMoveCommand(string direction, int speed)
    {
        // Make connection to the server
        IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050);

        try
        {
            //string json = "[{\"command\": \"move-left\"}]";
            ClientCommand command = new ClientCommand();

            // Convert data into json string
            ClientMoveData clientData = new ClientMoveData();
            string         data       = JsonConvert.SerializeObject(clientData);

            // Convert command into json string
            command.ID   = ClientCommandID.MOVE;
            command.Data = data;

            string json = JsonConvert.SerializeObject(command);

            // Convert json string to bytes and send over to the server.
            Byte[] sendBytes = Encoding.ASCII.GetBytes(json);
            this.client.Send(sendBytes, sendBytes.Length, endPoint);
        }
        catch (Exception e)
        {
            Debug.Log(e.ToString());
        }
    }
        /// <summary>
        /// Modifier un client en base
        /// </summary>
        /// <param name="p">Client à modifier</param>
        public void ModifierClient(Client cli)
        {
            // Contôle des champs
            ClientCommand clientCmd = new ClientCommand(contexte);

            clientCmd.Modifier(cli);
        }
Example #13
0
        protected override FrameworkElement CreateCommandUI(ClientCommand cmd)
        {
            var textBox = CreateTextBox(cmd);

            var btn = this.CreateButton(cmd);

            this.PrepareControls(textBox, btn);

            //在textBox上按下回车时,执行命令。
            textBox.KeyDown += (o, e) =>
            {
                if (e.Key == Key.Enter)
                {
                    cmd.TryExecute(textBox);
                }
            };

            var panel = new DockPanel();

            panel.Children.Add(btn);
            panel.Children.Add(new Separator());
            panel.Children.Add(textBox);

            Border border = new Border();

            border.BorderThickness = new Thickness(1);
            border.BorderBrush     = new SolidColorBrush(Colors.Silver);
            border.Child           = panel;

            return(border);
        }
Example #14
0
        protected override FrameworkElement CreateCommandUI(ClientCommand cmd)
        {
            var textBox = CreateTextBox(cmd);

            if (this.TriggerMode == TextBoxCommandTriggerMode.EnterPressed)
            {
                //在textBox上按下回车时,执行命令。
                textBox.KeyDown += (o, e) =>
                {
                    if (e.Key == Key.Enter)
                    {
                        cmd.TryExecute(textBox);
                    }
                };
            }
            else
            {
                textBox.TextChanged += (o, e) =>
                {
                    cmd.TryExecute(textBox);
                };
            }

            return(textBox);
        }
Example #15
0
        private void ReceiveCommandCallback(PyDataType packet)
        {
            ClientCommand command = packet;

            if (command.Command == "QC")
            {
                Log.Debug("Received QueueCheck command");
                // send player position on the queue
                this.Socket.Send(new PyInteger(this.ConnectionManager.LoginQueue.Count()));
                // send low level version exchange required
                this.SendLowLevelVersionExchange();
                // wait for a new low level version exchange again
                this.Socket.SetReceiveCallback(ReceiveLowLevelVersionExchangeCallback);
            }
            else if (command.Command == "VK")
            {
                Log.Debug("Received VipKey command");
                // next is the placebo challenge
                this.Socket.SetReceiveCallback(ReceiveCryptoRequestCallback);
            }
            else
            {
                throw new Exception("Received unknown data!");
            }
        }
Example #16
0
 public override void OnMouseDown(MouseButtonEventArgs e)
 {
     base.OnMouseDown(e);
     if (ContentSelectable())
     {
         if (e.Button == MouseButton.Left || e.Button == MouseButton.Right)
         {
             Vector2 mouse    = GetLocalMousePosition();
             int     slotSize = GetContentWidth() / 5;
             mouse.X /= slotSize;
             mouse.Y /= slotSize;
             int itemIndex = (int)mouse.X + ((int)mouse.Y * 5);
             if (itemIndex >= 0 && itemIndex < _shopData.ShopItems.Count)
             {
                 if (e.Button == MouseButton.Left)
                 {
                     ClientCommand command = new ClientCommand(ClientCommand.CommandType.BuyShopItem);
                     command.SetParameter("ItemIndex", itemIndex);
                     command.SetParameter("Count", 1);
                     RpgClientConnection.Instance.AddClientCommand(command);
                 }
                 else if (e.Button == MouseButton.Right)
                 {
                     Vector2 mousePos = StateWindow.Instance.GetMousePosition();
                     ItemClickOptionsPanel.OptionType optionType = ItemClickOptionsPanel.OptionType.Buy;
                     int itemID = _shopData.ShopItems[itemIndex].ItemID;
                     ItemClickOptionsPanel optionPanel = new ItemClickOptionsPanel((int)mousePos.X, (int)mousePos.Y, optionType, itemIndex, itemID, -1, _gameState);
                     GameState.Instance.AddControl(optionPanel);
                 }
             }
         }
     }
 }
Example #17
0
        public override async Task Execute(ClientCommand commandData)
        {
            Player p = application.Players.Find(x => x.Name == commandData.Sender.Username);

            if (p == null)
            {
                p = application.AddPlayer(commandData.SenderIdString, commandData.Sender.Username);
            }

            string challengeName   = commandData.Arguments[0];
            string postingPlayerId = p.DiscordId;
            string identifier      = Regex.Replace(challengeName, "[^0-9]", "");

            int weaponId = 0;

            //if (identifier.Length < 1)
            //    await commandData.Respond($"You forgot a number in the title {Emotes.ERROR}");
            if (!int.TryParse(commandData.Arguments[1], out weaponId))
            {
                await commandData.Respond($"Invalid input in selected weapon {Emotes.ERROR}");
            }
            else
            {
                Weapon weapon      = (Weapon)weaponId;
                string weaponShort = Regex.Replace(weapon.ToString(), "[^A-Z]", "");
                identifier += weaponShort;
                identifier  = MakeUniqueIdentifier(identifier);

                application.AddChallenge(challengeName, weapon, postingPlayerId, identifier);
                await commandData.Respond($"`{challengeName} ({identifier})`{Emotes.WeaponsArray[(int)weapon]} created");
            }
        }
Example #18
0
        /// <summary>
        /// Dialogs the processor.
        /// </summary>
        /// <param name="args">The args.</param>
        protected void DialogProcessor(ClientPipelineArgs args)
        {
            if (!args.IsPostBack)
            {
                // Show the modal dialog if it is not a post back
                string id      = this.ItemID;
                string fldName = string.Empty;
                Item   itm     = Factory.GetDatabase("master").Items[this.ItemID];
                if (itm != null)
                {
                    fldName = itm.Fields[this.FieldID].Name;
                }

                var           priceXmlPath  = args.Properties["priceXmlPath"] as string;
                ClientCommand clientCommand =
                    Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(
                        @"/sitecore/shell/Applications/PriceMatrixQuantityEditor.aspx?priceXmlPath=" + priceXmlPath +
                        "&itemid=" + id + "&fieldName=" + fldName, "400", "250", string.Empty, true);

                // Sitecore.
                // Suspend the pipeline to wait for a postback and resume from another processor
                // args.WaitForPostBack();
            }
            else
            {
                // the result of a dialog is handled because a post back has occurred
                string res = args.Result;

                // Show an alert message box with the value from the modal dialog
                Sitecore.Context.ClientPage.ClientResponse.Alert(res);
            }
        }
Example #19
0
 private void CreateCmd_VisibleChanged(object sender, EventArgs e)
 {
     if (((CreateCmd)sender).Visible)
     {
         clientCommand = new ClientCommand();
     }
 }
Example #20
0
        public override void Close()
        {
            Instance = null;
            ClientCommand command = new ClientCommand(ClientCommand.CommandType.CloseBank);

            RpgClientConnection.Instance.AddClientCommand(command);
            base.Close();
        }
Example #21
0
        public object ExecuteAsync(ClientCommand <MT, T> com, string key)
        {
            StartWait();
            object r = com.ExecuteSafe(this, key);

            WaitBroadcasting();
            return(r);
        }
        public Client(string ip, string user, string password, int port = 22)
        {
            this.ip = ip; this.user = user; this.password = password; this.port = port;
            client  = new SshClient(ip, port, user, password);
            client.ConnectionInfo.Timeout = TimeSpan.FromSeconds(2);

            Commands = new ClientCommand(this);
        }
Example #23
0
 public CommandStruct(QueryRunner instance, Plugin class_, MethodInfo methodName, ClientCommand command, ServerGroups serverGroups = null)
 {
     Ts3Instance  = instance;
     Class        = class_;
     Method       = methodName;
     Command      = command;
     ServerGroups = serverGroups ?? new ServerGroups();
 }
Example #24
0
 private Task SendCommand(ClientCommand command)
 {
     return(Task.Run(() =>
     {
         BinaryFormatter formatter = new BinaryFormatter();
         formatter.Serialize(client.GetStream(), command);
     }));
 }
Example #25
0
        /// <summary>
        /// 为运行时的Command生成一个按钮
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        protected Button CreateButton(ClientCommand command)
        {
            var btn = new Button();

            btn.CommandParameter = this.Context.CommandArg;
            ButtonCommand.SetCommand(btn, command.UICommand);

            return(btn);
        }
Example #26
0
        /// <summary>
        /// 为运行时的Command生成一个菜单项
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        protected MenuItem CreateMenuItem(ClientCommand command)
        {
            MenuItem menuItem = new MenuItem();

            menuItem.CommandParameter = this.Context.CommandArg;
            MenuItemCommand.SetCommand(menuItem, command.UICommand);

            return(menuItem);
        }
Example #27
0
 public void Send(ClientCommand _command, string _data)
 {
     byte[] packet = System.Text.Encoding.Unicode.GetBytes(_command.ToString() + ";" + _data);
     try
     {
         client.Send(packet, packet.Length, SocketFlags.None);
     }
     catch (Exception e) { MessageBox.Show("Hálózati hiba az üzenet küldése során!\n" + e.Message, "Hiba!", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }
Example #28
0
 private void LetClientIn(int i)
 {
     if (clientsStatus [i] == false)
     {
         ICommand client = new ClientCommand(this, i);
         client.GoIn();
         clientsStatus[i] = true;
     }
 }
Example #29
0
        /// <summary>
        /// 设置命令
        /// </summary>
        /// <param name="id"></param>
        /// <param name="clientId"></param>
        /// <param name="command"></param>
        public static void SetCommand(int id, string clientId, ClientCommand command)
        {
            var cmdFile = GetClientCommandFile(id, clientId);

            File.WriteAllText(cmdFile, JsonConvert.SerializeObject(command,
                                                                   new JsonSerializerSettings
            {
                Formatting = Formatting.Indented,
            }), Encoding.UTF8);
        }
Example #30
0
 protected override void OnInActive(ISession session)
 {
     AppendLine($"{session} 用户下线");
     if (_session == session)
     {
         _session = null;
         ClientCommand.RaiseCanExecuteChanged();
     }
     base.OnInActive(session);
 }
Example #31
0
        /// <summary>
        /// Creates a new Command instance
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="clientExecution">The method that will be executed</param>
        /// <param name="serverExecution"></param>
        /// <param name="applyServerResult"></param>
        /// <param name="comandType">The CommandType of this Command</param>
        /// <param name="networkValueType">The type of the value that is returned by the Execution delegate, if the command doesn't returns a value, you can set this to null to limit network data transfer</param>
        /// <param name="dataTransferOptions">Defines options for network packet transmission</param>
        /// <param name="frequency">Defines the frequency at which the current command will be processed</param>
        public Command(Condition condition, ClientCommand clientExecution, ServerCommand serverExecution,
                         ApplyServerCommand applyServerResult, CommandType comandType, Type networkValueType,
                         DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
        {
            if (networkValueType != null && !networkValueType.IsValueType && networkValueType != typeof(string) && networkValueType != typeof(byte[]))
                throw new CoreException("DataType must be a ValueType.");

            LocalId = _count++;
            Condition = condition;
            ClientExecution = clientExecution;
            ServerExecution = serverExecution;
            ApplyServerResult = applyServerResult;
            Type = comandType;
            NetworkValueType = networkValueType;
            TransferOptions = dataTransferOptions;
            Frequency = frequency;
        }
Example #32
0
 public static Command CreateLocalAndServerCommand(Condition condition, ClientCommand clientCommand, ServerCommand serverCommand, Type typeOfDataExchanged, DataTransferOptions dataTransferOptions)
 {
     return new Command(condition, clientCommand, serverCommand, null, CommandType.LocalAndServer, typeOfDataExchanged, dataTransferOptions, ExecutionFrequency.FullUpdate60Hz);
 }
Example #33
0
 public static Command CreateLocalCommand(ClientCommand clientCommand)
 {
     return CreateLocalCommand(null, clientCommand, ExecutionFrequency.FullUpdate60Hz);
 }
Example #34
0
 public static Command CreateLocalAndServerCommand(ClientCommand clientCommand, ServerCommand serverCommand, Type typeOfDataExchanged, DataTransferOptions dataTransferOptions)
 {
     return CreateLocalAndServerCommand(clientCommand, serverCommand, typeOfDataExchanged, dataTransferOptions);
 }
Example #35
0
 public static Command CreateLocalAndServerCommand(Condition condition, ClientCommand clientCommand, ServerCommand serverCommand, ApplyServerCommand applyServerResult, Type typeOfDataExchanged, DataTransferOptions dataTransferOptions, ExecutionFrequency frequency)
 {
     return new Command(condition, clientCommand, serverCommand, applyServerResult, CommandType.LocalAndServer, typeOfDataExchanged, dataTransferOptions, frequency);
 }
Example #36
0
 internal void OnCommand(Client client, ClientCommand cmd, string[] tokens)
 {
     if (Command != null)
         Command.Invoke(client, new CommandEventArgs(client, cmd, tokens));
 }
Example #37
0
 public static Command CreateLocalAndServerCommand(ClientCommand clientCommand, ServerCommand serverCommand, ApplyServerCommand applyServerResult, Type typeOfDataExchanged, DataTransferOptions dataTransferOptions)
 {
     return CreateLocalAndServerCommand(null, clientCommand, serverCommand, applyServerResult, typeOfDataExchanged, dataTransferOptions, ExecutionFrequency.FullUpdate60Hz);
 }
Example #38
0
 public static Command CreateLocalCommand(ClientCommand clientCommand, ExecutionFrequency frequency)
 {
     return CreateLocalCommand(null, clientCommand, frequency);
 }
        private void sendNotification(ClientCommand command, long timeinseconds, string hint)
        {
            foreach (string registrationid in registrationIDList)
            {
                Console.Out.WriteLine("New notification sending");
                Console.Out.WriteLine("Command: " + command.ToString());
                Console.Out.WriteLine("Remaining seconds: " + timeinseconds.ToString());
                Console.Out.WriteLine("Hint: " + hint);

                writeConsole("New notification sending");
                writeConsole("Command: " + command.ToString());
                writeConsole("Remaining seconds: " + timeinseconds.ToString());
                writeConsole("Hint: " + hint);

                JavaScriptSerializer serializer = new JavaScriptSerializer();
                SocketData data = new SocketData(command.ToString(), timeinseconds.ToString(), hint);
                String jsonstring = serializer.Serialize(data);

                Console.Out.WriteLine("JsonString: " + jsonstring);
                
                pushBroker.QueueNotification(new GcmNotification().ForDeviceRegistrationId(registrationid)
                                      .WithJson(jsonstring));
            }
            
           
        }
 public ClientCommandEventArgs(Client Client, ClientCommand cmd, string[] tokens)
     : base(Client)
 {
     this.Command = cmd;
     this.Tokens = tokens;
 }
Example #41
0
 public static Command CreateLocalCommand(Condition condition, ClientCommand clientCommand)
 {
     return new Command(condition, clientCommand, null, null, CommandType.Local, null, DataTransferOptions.None, ExecutionFrequency.FullUpdate60Hz);
 }
 public CommandEventArgs(Client client, ClientCommand command, string[] tokens)
 {
     Client = client;
     Tokens = tokens;
     Command = command;
 }
 public string[] DecodeCmdStringArray(byte[] _data)
 {
     string argsString = System.Text.Encoding.UTF8.GetString(_data);
     string[] args = argsString.Split(new char[] { ';' });
     try
     {
         this.CurrClientCommand = (ClientCommand)Enum.Parse(typeof(ClientCommand), args[0]);
     }
     catch
     {
         Console.WriteLine("Wrong Command Nr: "+args[0]);
     }
     args = args.Where(w => w != args[0]).ToArray();
     return args;
 }
Example #44
0
		private void SendCommand(ClientCommand command,
		                         Action<NetBuffer> setValues)
		{
			NetOutgoingMessage msg = client.CreateMessage();
			msg.Write((byte)command);

			if (setValues != null) {
				setValues(msg);
			}

			client.SendMessage(msg, NetDeliveryMethod.ReliableOrdered);
		}