当前位置: 首页>>代码示例>>C#>>正文


C# Client.SendMessage方法代码示例

本文整理汇总了C#中Client.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Client.SendMessage方法的具体用法?C# Client.SendMessage怎么用?C# Client.SendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


在下文中一共展示了Client.SendMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Use

 public void Use(Client client, string[] tokens)
 {
     int newTime = -1;
     if (tokens.Length < 2)
     {
         client.SendMessage("You must specify an explicit time, day, or night.");
         return;
     }
     if (int.TryParse(tokens[1], out newTime) && newTime >= 0 && newTime <= 24000)
     {
         client.World.Time = newTime;
     }
     else if (tokens[1].ToLower() == "day")
     {
         client.World.Time = 0;
     }
     else if (tokens[1].ToLower() == "night")
     {
         client.World.Time = 12000;
     }
     else
     {
         client.SendMessage("You must specify a time value between 0 and 24000");
         return;
     }
     client.Server.Broadcast(new TimeUpdatePacket { Time = client.World.Time });
 }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:27,代码来源:CmdTime.cs

示例2: Use

        public void Use(Client client, string[] tokens)
        {
            if (client.Point2 == null || client.Point1 == null)
            {
                client.SendMessage("§cPlease select a cuboid first.");
                return;
            }

            PointI start = client.SelectionStart.Value;
            PointI end = client.SelectionEnd.Value;

            ItemStack item = client.Server.Items[tokens[1]];
            if (ItemStack.IsVoid(item))
            {
                client.SendMessage("§cUnknown item.");
                return;
            }

            if (item.Type > 255)
            {
                client.SendMessage("§cInvalid item.");
            }

            for (int x = start.X; x <= end.X; x++)
            {
                for (int y = start.Y; y <= end.Y; y++)
                {
                    for (int z = start.Z; z <= end.Z; z++)
                    {
                        client.World.SetBlockAndData(x, y, z, (byte)item.Type, (byte)item.Durability);
                    }
                }
            }
        }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:34,代码来源:CmdSet.cs

示例3: Use

 public void Use(Client client, string[] tokens)
 {
     if (tokens.Length < 2)
     {
         client.SendMessage("§cUsage <player> <mode>");
         return;
     }
     Client c = client.Server.GetClients(tokens[1]).FirstOrDefault();
     if (c != null)
     {
         if (c.GameMode == Convert.ToByte(tokens[2]))
         {
             client.SendMessage("§7You are already in that mode");
             return;
         }
         c.SendPacket(new NewInvalidStatePacket
                               {
                                   GameMode = c.GameMode = Convert.ToByte(tokens[2]),
                                   Reason = NewInvalidStatePacket.NewInvalidReason.ChangeGameMode
                               });
     }
     else
     {
         client.SendMessage(string.Format("§cPlayer {0} not found", tokens[1]));
     }
 }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:26,代码来源:CmdGameMode.cs

示例4: Use

        public void Use(Client client, string[] tokens)
        {
            if (tokens.Length == 1)
            {
                client.SendMessage(String.Format("§7Your position: X={0:0.00},Y={1:0.00},Z={2:0.00}, Yaw={3:0.00}, Pitch={4:0.00}", client.Position.X, client.Position.Y, client.Position.Z, client.Position.Yaw, client.Position.Pitch));
            }
            else if (tokens[1] == "yaw")
            {
                Vector3 z1 = client.Position.Vector + Vector3.ZAxis;
                Vector3 posToZ1 = (client.Position.Vector - z1);

                client.SendMessage(String.Format("§7Player.Position.Yaw {0:0.00}, vector computed yaw (SignedAngle) {1:0.00}", client.Position.Yaw % 360, Vector3.ZAxis.SignedAngle(Vector3.ZAxis.Yaw(client.Position.Yaw.ToRadians()), Vector3.ZAxis.Yaw(client.Position.Yaw.ToRadians()).Yaw(90.0.ToRadians())).ToDegrees()));
                client.SendMessage(String.Format("§7Normalised facing Yaw: " + client.Position.Vector.Normalize().Yaw(client.Position.Yaw % 360).ToString()));
            }
        }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:15,代码来源:DbgPos.cs

示例5: Use

        public void Use(Client client, string[] tokens)
        {
            ItemStack item;
            uint amount = 0;
            List<Client> who = new List<Client>();

            if (tokens.Length < 2)
            {
                client.SendMessage("§cPlease specify an item and target or just an item to give it to yourself.");
                return;
            }
            item = client.Server.Items[tokens[1]];

            if (tokens.Length == 2)
            {
                // Trying to give something to yourself
                who.Add(client);
            }
            else if (tokens.Length == 3)
            {
                // Trying to give yourself an item with amount specified
                if (uint.TryParse(tokens[2], out amount))
                {
                    who.Add(client);
                }
                else
                {
                    // OR trying to give something to a player(s)
                    who.AddRange(client.Server.GetClients(tokens[2]));
                }
            }
            else
            {
                // Trying to give item to other player with amount specified
                if (uint.TryParse(tokens[3], out amount))
                {
                    who.AddRange(client.Server.GetClients(tokens[2]));
                }

            }

            if (ItemStack.IsVoid(item))
            {
                client.SendMessage("§cUnknown item.");
                return;
            }

            if (who.Count < 1)
            {
                client.SendMessage("§cUnknown player.");
                return;
            }

            if (amount > 0)
                item.Count = (sbyte)amount;

            foreach (Client c in who)
                c.Inventory.AddItem(item.Type, item.Count, item.Durability);
            client.SendMessage("§7Item given to " + who.Count + " player" + (who.Count > 1 ? "s":""));
        }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:60,代码来源:CmdGive.cs

示例6: NewGame

        public void NewGame(Client first, Client second)
        {
            Random random = new Random();
            int order = random.Next(0, 2);
            first.SendMessage(protocol.ToMessage(new Command(Command.Commands.StartGame, order.ToString())));
            second.SendMessage(protocol.ToMessage(new Command(Command.Commands.StartGame, (order ^ 1).ToString())));

            Game game = new Game(first, second, order);
            game.GameFinishEvent += GameFinish;
            gameList.Add(game);

            //move to game
            new Thread(delegate()
                {
                    Thread.Sleep(500);

                    if (order == 1)
                    {
                        first.SendMessage(protocol.ToMessage(new Command(Command.Commands.YourStep, game.StepPlayerGameField)));
                        second.SendMessage(protocol.ToMessage(new Command(Command.Commands.OpponentStep, game.NextPlayerGameField)));
                    }
                    else
                    {
                        first.SendMessage(protocol.ToMessage(new Command(Command.Commands.OpponentStep, game.StepPlayerGameField)));
                        second.SendMessage(protocol.ToMessage(new Command(Command.Commands.YourStep, game.NextPlayerGameField)));
                    }
                }).Start();
        }
开发者ID:vit2005,项目名称:TicTacToe,代码行数:28,代码来源:GameManager.cs

示例7: TestSendMessageInvalidDomain

        public void TestSendMessageInvalidDomain()
        {
            var client = new Client(ApiKey) { BaseUri = "http://0.0.0.0/" };

            var threwException = false;
            try
            {
                var message = new Message.Message
                {
                    Uid = Guid.NewGuid().ToString(),
                    Recipient = new Recipient("[email protected]"),
                    RecipientOverride = RecipientOverride,
                    Text = "This is my text content"
                };

                client.SendMessage(message);
            }
            catch (PostageResponseException<MessageResponse> exception)
            {
                threwException = true;
                Assert.IsNull(exception.ResponseContainer);
            }

            Assert.IsTrue(threwException);
        }
开发者ID:postageapp,项目名称:postageapp-net,代码行数:25,代码来源:ClientTest.cs

示例8: Use

        public void Use(Client client, string[] tokens)
        {
            if (tokens.Length < 2)
            {
                client.SendMessage("You must specify a player to mute");
                return;
            }

            Client[] matchedClients = client.Server.GetClients(tokens[1]).ToArray();
            Client clientToMute = null;
            if (matchedClients.Length < 1)
            {
                client.SendMessage("Unknown Player");
                return;
            }
            else if (matchedClients.Length == 1)
            {
                clientToMute = matchedClients[0];
            }
            else if (matchedClients.Length > 1)
            {
                // We've got more than 1 client. I.e. "Test" and "Test123" for the "test" pattern.
                // Looking for exact name match.
                int exactMatchClient = -1;
                for (int i = 0; i < matchedClients.Length; i++)
                {
                    if (matchedClients[i].DisplayName.ToLower() == tokens[1].ToLower())
                        exactMatchClient = i;
                }

                // If we found the player with the exactly same name - he is our target
                if (exactMatchClient != -1)
                {
                    clientToMute = matchedClients[exactMatchClient];
                } else
                {
                    // We do not found a proper target and aren't going to randomly punish anyone
                    client.SendMessage("More than one player found. Provide the exact name.");
                    return;
                }
            }
            bool clientMuted = clientToMute.IsMuted;
            clientToMute.IsMuted = !clientMuted;
            clientToMute.SendMessage(clientMuted ? "You have been unmuted" : "You have been muted");
            client.SendMessage(clientMuted ? clientToMute.DisplayName + " has been unmuted" : clientToMute.DisplayName + " has been muted");
        }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:46,代码来源:CmdMute.cs

示例9: Use

 public void Use(Client client, string[] tokens)
 {
     if (tokens.Length < 2)
     {
         client.SendMessage("§cPlease specify a target.");
         return;
     }
     Client[] targets = client.Server.GetClients(tokens[1]).ToArray();
     if (targets.Length < 1)
     {
         client.SendMessage("§cUnknown payer.");
         return;
     }
     foreach (Client c in targets)
     {
         c.World = client.World;
         c.TeleportTo(client.Position.X, client.Position.Y, client.Position.Z);
     }
 }
开发者ID:RevolutionSmythe,项目名称:c-raft,代码行数:19,代码来源:CmdTp.cs

示例10: Use

        public void Use(Client client, string[] tokens)
        {
            if (tokens.Length < 2)
            {
                client.SendMessage("You must specify a player to mute");
                return;
            }

            Client[] muteClient = client.Server.GetClients(tokens[1]).ToArray();
            if (muteClient.Length < 1)
            {
                client.SendMessage("Unknown Player");
                return;
            }
            bool clientMuted = muteClient[0].IsMuted;
            muteClient[0].IsMuted = !clientMuted;
            muteClient[0].SendMessage(clientMuted ? "You have been unmuted" : "You have been muted");
            client.SendMessage(clientMuted ? tokens[1] + " has been unmuted" : tokens[1] + " has been muted");
        }
开发者ID:Farkie,项目名称:c-raft,代码行数:19,代码来源:CmdMute.cs

示例11: Use

        public void Use(Client client, string[] tokens)
        {
            if (tokens.Length < 3)
            {
                client.SendMessage("§cPlease specify an item and target.");
                return;
            }

            ItemStack item = client.Server.Items[tokens[2]];
            if (ItemStack.IsVoid(item))
            {
                client.SendMessage("§cUnknown item.");
                return;
            }

            sbyte count = -1;
            if (tokens.Length > 3)
                sbyte.TryParse(tokens[3], out count);

            foreach (Client c in client.Server.GetClients(tokens[1]))
                c.Inventory.AddItem(item.Type, count < 0 ? item.Count : count, item.Durability);
            client.SendMessage("§7Item given.");
        }
开发者ID:Eipok,项目名称:c-raft,代码行数:23,代码来源:CmdGive.cs

示例12: Help

 public void Help(Client client)
 {
     client.SendMessage("Shuts down the server.");
 }
开发者ID:cyberdudedk,项目名称:c-raft,代码行数:4,代码来源:CmdStop.cs

示例13: TestSendMessageWithHtmlContent

        public void TestSendMessageWithHtmlContent()
        {
            var client = new Client(ApiKey);

            var responseContainer = client.SendMessage(new Message.Message
                {
                    Uid = Guid.NewGuid().ToString(),
                    Subject = "Html body",
                    Recipient = new Recipient("[email protected]"),
                    RecipientOverride = RecipientOverride,
                    Text = "This email should have some html content.",
                    Html = "<h1>Title</h1><p>This is an <em>html email</em></p></h1>"
                });

            Assert.AreEqual(ResponseStatus.Ok, responseContainer.Response.Status);
        }
开发者ID:postageapp,项目名称:postageapp-net,代码行数:16,代码来源:ClientTest.cs

示例14: TestGetMessageReceiptSuccess

        public void TestGetMessageReceiptSuccess()
        {
            var client = new Client(ApiKey);

            var message = new Message.Message
            {
                Uid = Guid.NewGuid().ToString(),
                Recipient = new Recipient("[email protected]"),
                RecipientOverride = RecipientOverride,
                Text = "This is my text content"
            };

            var sendResponseContainer = client.SendMessage(message);

            var responseContainer = client.GetMessageReceipt(sendResponseContainer.Response.Uid);

            Assert.AreEqual(ResponseStatus.Ok, responseContainer.Response.Status);
            Assert.AreEqual(sendResponseContainer.Data.Id, responseContainer.Data.Id);
        }
开发者ID:postageapp,项目名称:postageapp-net,代码行数:19,代码来源:ClientTest.cs

示例15: Use

 public void Use(Client client, string[] tokens)
 {
     client.Point1 = new PointI((int)client.Position.X, (int)client.Position.Y, (int)client.Position.Z);
     client.SendMessage("§7Second position set.");
 }
开发者ID:Eipok,项目名称:c-raft,代码行数:5,代码来源:CmdPos.cs


注:本文中的Client.SendMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。