コード例 #1
0
        public void SendMoveCommand(CellCoord moveCoord)
        {
            ServerCommand command = new ServerCommand(CommandType.MOVE)
            {
                MoveCoord = moveCoord
            };

            SendCommand(command);
        }
コード例 #2
0
        public void SendStartCommand(string opponentName)
        {
            ServerCommand command = new ServerCommand(CommandType.START)
            {
                IsX          = this.IsX,
                OpponentName = opponentName
            };

            SendCommand(command);
        }
コード例 #3
0
        public void SendLoseCommand(string opponentName)
        {
            ServerCommand command = new ServerCommand(CommandType.LOSE)
            {
                OpponentName = opponentName
            };


            SendCommand(command);
        }
コード例 #4
0
ファイル: GameCore.cs プロジェクト: guillobits/net_unogame
        private void ReadServerCommands()
        {
            Console.WriteLine("");
            DisplayHelpCommands();
            Console.Write("$> ");
            var line = Console.ReadLine();

            while (line != null && read)
            {
                ServerCommand.ExecuteCommand(line, Table, this);
                Console.Write("$> ");
                line = Console.ReadLine();
            }
        }
コード例 #5
0
ファイル: ClientsManager.cs プロジェクト: janwaltl/tank_game
        /// <summary>
        /// Sends a ServerCommand to a client from connectClients.
        /// </summary>
        /// <param name="pID">ID of the client.</param>
        /// <param name="cmd">Command to send.</param>
        public async Task SendServerCommandAsync(int pID, ServerCommand cmd)
        {
            if (connectedClients.TryGetValue(pID, out ConnectedClient client))
            {
                if (cmd.guaranteedExec)
                {
                    var bytes = Serialization.PrependInt(new CmdServerUpdate(cmd).Encode(), client.lastPolledCUpdate);
                    await Task.Delay(sendDelay);

                    await Communication.TCPSendMessageAsync(client.relUpdateSocket, bytes);
                }
                else
                {
                    var bytes = Serialization.PrependInt(cmd.Encode(), client.lastPolledCUpdate);
                    if (random.NextDouble() < packetLoss)
                    {
                        return;
                    }
                    await Task.Delay(sendDelay);

                    await Communication.UDPSendMessageAsync(serverCommandsSender, client.updateAddress, bytes);
                }
            }
        }
コード例 #6
0
        // метод для відправки об'єкту команди
        private void SendCommand(ServerCommand command)
        {
            BinaryFormatter formatter = new BinaryFormatter();

            formatter.Serialize(TcpClient.GetStream(), command);
        }
コード例 #7
0
        public void SendDrawCommand()
        {
            ServerCommand command = new ServerCommand(CommandType.DRAW);

            SendCommand(command);
        }