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


C# Server.SendMessage方法代码示例

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


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

示例1: Tick

		public void Tick(S server)
		{
			if ((Game.RunTime - lastPing > MasterPingInterval * 1000) || isInitialPing)
				PingMasterServer(server);
			else
				lock (masterServerMessages)
					while (masterServerMessages.Count > 0)
						server.SendMessage(masterServerMessages.Dequeue());
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:9,代码来源:MasterServerPinger.cs

示例2: Tick

        public void Tick(S server)
        {
            if ((Game.RunTime - lastPing > PingInterval) || isInitialPing)
            {
                isInitialPing = false;
                lastPing = Game.RunTime;
                foreach (var c in server.Conns.ToList())
                {
                    if (c.TimeSinceLastResponse < ConnTimeout)
                    {
                        server.SendOrderTo(c, "Ping", Game.RunTime.ToString());
                        if (!c.TimeoutMessageShown && c.TimeSinceLastResponse > PingInterval * 2)
                        {
                            server.SendMessage(server.GetClient(c).Name + " is experiencing connection problems.");
                            c.TimeoutMessageShown = true;
                        }
                    }
                    else
                    {
                        server.SendMessage(server.GetClient(c).Name + " has been dropped after timing out.");
                        server.DropClient(c, -1);
                    }
                }
            }

            if (Game.RunTime - lastConnReport > ConnReportInterval)
            {
                lastConnReport = Game.RunTime;

                var timeouts = server.Conns
                    .Where(c => c.TimeSinceLastResponse > ConnReportInterval && c.TimeSinceLastResponse < ConnTimeout)
                    .OrderBy(c => c.TimeSinceLastResponse);

                foreach (var c in timeouts)
                    server.SendMessage("{0} will be dropped in {1} seconds.".F(
                        server.GetClient(c).Name, (ConnTimeout - c.TimeSinceLastResponse) / 1000));
            }
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:38,代码来源:PlayerPinger.cs

示例3: InterpretCommand


//.........这里部分代码省略.........
                            //  - Observers remain as observers
                            //  - Players who now lack a slot are made observers
                            //  - Bots who now lack a slot are dropped
                            //  - Bots who are not defined in the map rules are dropped
                            var botNames = server.Map.Rules.Actors["player"].TraitInfos<IBotInfo>().Select(t => t.Name);
                            var slots = server.LobbyInfo.Slots.Keys.ToArray();
                            var i = 0;
                            foreach (var os in oldSlots)
                            {
                                var c = server.LobbyInfo.ClientInSlot(os);
                                if (c == null)
                                    continue;

                                c.SpawnPoint = 0;
                                c.Slot = i < slots.Length ? slots[i++] : null;
                                if (c.Slot != null)
                                {
                                    // Remove Bot from slot if slot forbids bots
                                    if (c.Bot != null && (!server.Map.Players.Players[c.Slot].AllowBots || !botNames.Contains(c.Bot)))
                                        server.LobbyInfo.Clients.Remove(c);
                                    S.SyncClientToPlayerReference(c, server.Map.Players.Players[c.Slot]);
                                }
                                else if (c.Bot != null)
                                    server.LobbyInfo.Clients.Remove(c);
                            }

                            // Validate if color is allowed and get an alternative if it isn't
                            foreach (var c in server.LobbyInfo.Clients)
                                if (c.Slot == null || (c.Slot != null && !server.LobbyInfo.Slots[c.Slot].LockColor))
                                    c.Color = c.PreferredColor = SanitizePlayerColor(server, c.Color, c.Index, conn);

                            server.SyncLobbyInfo();

                            server.SendMessage("{0} changed the map to {1}.".F(client.Name, server.Map.Title));

                            if (server.Map.DefinesUnsafeCustomRules)
                                server.SendMessage("This map contains custom rules. Game experience may change.");

                            if (server.Settings.DisableSinglePlayer)
                                server.SendMessage("Singleplayer games have been disabled on this server.");
                            else if (server.Map.Players.Players.Where(p => p.Value.Playable).All(p => !p.Value.AllowBots))
                                server.SendMessage("Bots have been disabled on this map.");
                        };

                        Action queryFailed = () =>
                            server.SendOrderTo(conn, "Message", "Map was not found on server.");

                        var m = server.ModData.MapCache[s];
                        if (m.Status == MapStatus.Available || m.Status == MapStatus.DownloadAvailable)
                            selectMap(m);
                        else if (server.Settings.QueryMapRepository)
                        {
                            server.SendOrderTo(conn, "Message", "Searching for map on the Resource Center...");
                            server.ModData.MapCache.QueryRemoteMapDetails(new[] { s }, selectMap, queryFailed);
                        }
                        else
                            queryFailed();

                        return true;
                    }
                },
                { "allowcheats",
                    s =>
                    {
                        if (!client.IsAdmin)
                        {
开发者ID:CH4Code,项目名称:OpenRA,代码行数:67,代码来源:LobbyCommands.cs

示例4: InterpretCommand


//.........这里部分代码省略.........
						// Reassign players into new slots based on their old slots:
						//  - Observers remain as observers
						//  - Players who now lack a slot are made observers
						//  - Bots who now lack a slot are dropped
						var slots = server.LobbyInfo.Slots.Keys.ToArray();
						var i = 0;
						foreach (var os in oldSlots)
						{
							var c = server.LobbyInfo.ClientInSlot(os);
							if (c == null)
								continue;

							c.SpawnPoint = 0;
							c.Slot = i < slots.Length ? slots[i++] : null;
							if (c.Slot != null)
							{
								// Remove Bot from slot if slot forbids bots
								if (c.Bot != null && !server.MapPlayers.Players[c.Slot].AllowBots)
									server.LobbyInfo.Clients.Remove(c);
								S.SyncClientToPlayerReference(c, server.MapPlayers.Players[c.Slot]);
							}
							else if (c.Bot != null)
								server.LobbyInfo.Clients.Remove(c);
						}

						foreach (var c in server.LobbyInfo.Clients)
						{
							// Validate if color is allowed and get an alternative it it isn't
							c.Color = c.PreferredColor = ColorValidator.ValidatePlayerColorAndGetAlternative(server, c.Color, c.Index, conn);
						}

						server.SyncLobbyInfo();

						server.SendMessage("{0} changed the map to {1}.".F(client.Name, server.Map.Title));

						if (server.Map.RuleDefinitions.Any())
							server.SendMessage("This map contains custom rules. Game experience may change.");

						return true;
					}
				},
				{ "fragilealliance",
					s =>
					{
						if (!client.IsAdmin)
						{
							server.SendOrderTo(conn, "Message", "Only the host can set that option.");
							return true;
						}

						if (server.Map.Options.FragileAlliances.HasValue)
						{
							server.SendOrderTo(conn, "Message", "Map has disabled alliance configuration.");
							return true;
						}

						bool.TryParse(s, out server.LobbyInfo.GlobalSettings.FragileAlliances);
						server.SyncLobbyGlobalSettings();
						server.SendMessage("{0} {1} Diplomacy Changes."
							.F(client.Name, server.LobbyInfo.GlobalSettings.FragileAlliances ? "enabled" : "disabled"));

						return true;
					}
				},
				{ "allowcheats",
					s =>
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:67,代码来源:LobbyCommands.cs

示例5: Tick

		public void Tick(S server)
		{
			if ((Game.RunTime - lastPing > PingInterval) || isInitialPing)
			{
				isInitialPing = false;
				lastPing = Game.RunTime;

				// Ignore client timeout in singleplayer games to make debugging easier
				if (server.LobbyInfo.IsSinglePlayer && !server.Settings.Dedicated)
					foreach (var c in server.Conns.ToList())
						server.SendOrderTo(c, "Ping", Game.RunTime.ToString());
				else
				{
					foreach (var c in server.Conns.ToList())
					{
						if (c == null || c.Socket == null)
							continue;

						var client = server.GetClient(c);
						if (client == null)
						{
							server.DropClient(c, -1);
							server.SendMessage("A player has been dropped after timing out.");
							continue;
						}

						if (c.TimeSinceLastResponse < ConnTimeout)
						{
							server.SendOrderTo(c, "Ping", Game.RunTime.ToString());
							if (!c.TimeoutMessageShown && c.TimeSinceLastResponse > PingInterval * 2)
							{
								server.SendMessage(client.Name + " is experiencing connection problems.");
								c.TimeoutMessageShown = true;
							}
						}
						else
						{
							server.SendMessage(client.Name + " has been dropped after timing out.");
							server.DropClient(c, -1);
						}
					}

					if (Game.RunTime - lastConnReport > ConnReportInterval)
					{
						lastConnReport = Game.RunTime;

						var timeouts = server.Conns
							.Where(c => c.TimeSinceLastResponse > ConnReportInterval && c.TimeSinceLastResponse < ConnTimeout)
							.OrderBy(c => c.TimeSinceLastResponse);

						foreach (var c in timeouts)
						{
							if (c == null || c.Socket == null)
								continue;

							var client = server.GetClient(c);
							if (client != null)
								server.SendMessage("{0} will be dropped in {1} seconds.".F(client.Name, (ConnTimeout - c.TimeSinceLastResponse) / 1000));
						}
					}
				}
			}
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:63,代码来源:PlayerPinger.cs


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