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


C# Server.SendChat方法代码示例

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


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

示例1: ClientJoined

        public void ClientJoined(S server, Connection newConn)
        {
            var defaults = new GameRules.PlayerSettings();

            var client = new Session.Client()
            {
                Index = newConn.PlayerIndex,
                Color1 = defaults.Color1,
                Color2 = defaults.Color2,
                Name = defaults.Name,
                Country = "random",
                State = Session.ClientState.NotReady,
                SpawnPoint = 0,
                Team = 0,
                Slot = ChooseFreeSlot(server),
            };

            var slotData = server.lobbyInfo.Slots.FirstOrDefault( x => x.Index == client.Slot );
            if (slotData != null)
                SyncClientToPlayerReference(client, server.Map.Players[slotData.MapPlayer]);

            server.lobbyInfo.Clients.Add(client);

            Log.Write("server", "Client {0}: Accepted connection from {1}",
                newConn.PlayerIndex, newConn.socket.RemoteEndPoint);

            server.SendChat(newConn, "has joined the game.");
            server.SyncLobbyInfo();
        }
开发者ID:geckosoft,项目名称:OpenRA,代码行数:29,代码来源:LobbyCommands.cs

示例2: Tick

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

示例3: InterpretCommand

        public bool InterpretCommand(S server, Connection conn, Session.Client client, string cmd)
        {
            if (!ValidateCommand(server, conn, client, cmd))
                return false;

            var dict = new Dictionary<string, Func<string, bool>>
            {
                { "ready",
                    s =>
                    {
                        // if we're downloading, we can't ready up.
                        if (client.State == Session.ClientState.NotReady)
                            client.State = Session.ClientState.Ready;
                        else if (client.State == Session.ClientState.Ready)
                            client.State = Session.ClientState.NotReady;

                        Log.Write("server", "Player @{0} is {1}",
                            conn.socket.RemoteEndPoint, client.State);

                        server.SyncLobbyInfo();

                        CheckAutoStart(server, conn, client);

                        return true;
                    }},
                { "startgame",
                    s =>
                    {
                        if (server.lobbyInfo.Slots.Any(sl => sl.Value.Required &&
                            server.lobbyInfo.ClientInSlot(sl.Key) == null))
                        {
                            server.SendChat(conn, "Unable to start the game until required slots are full.");
                            return true;
                        }
                        server.StartGame();
                        return true;
                    }},
                { "lag",
                    s =>
                    {
                        int lag;
                        if (!int.TryParse(s, out lag)) { Log.Write("server", "Invalid order lag: {0}", s); return false; }

                        Log.Write("server", "Order lag is now {0} frames.", lag);

                        server.lobbyInfo.GlobalSettings.OrderLatency = lag;
                        server.SyncLobbyInfo();
                        return true;
                    }},
                { "slot",
                    s =>
                    {
                        if (!server.lobbyInfo.Slots.ContainsKey(s))
                        {
                            Log.Write("server", "Invalid slot: {0}", s );
                            return false;
                        }
                        var slot = server.lobbyInfo.Slots[s];

                        if (slot.Closed || server.lobbyInfo.ClientInSlot(s) != null)
                            return false;

                        client.Slot = s;
                        S.SyncClientToPlayerReference(client, server.Map.Players[s]);

                        server.SyncLobbyInfo();
                        CheckAutoStart(server, conn, client);

                        return true;
                    }},
                { "spectate",
                    s =>
                    {
                        client.Slot = null;
                        client.SpawnPoint = 0;
                        server.SyncLobbyInfo();
                        return true;
                    }},
                { "slot_close",
                    s =>
                    {
                        if (!ValidateSlotCommand( server, conn, client, s, true ))
                            return false;

                        // kick any player that's in the slot
                        var occupant = server.lobbyInfo.ClientInSlot(s);
                        if (occupant != null)
                        {
                            if (occupant.Bot != null)
                                server.lobbyInfo.Clients.Remove(occupant);
                            else
                            {
                                var occupantConn = server.conns.FirstOrDefault( c => c.PlayerIndex == occupant.Index );
                                if (occupantConn != null)
                                {
                                    server.SendOrderTo(occupantConn, "ServerError", "Your slot was closed by the host");
                                    server.DropClient(occupantConn);
                                }
                            }
                        }
//.........这里部分代码省略.........
开发者ID:nevelis,项目名称:OpenRA,代码行数:101,代码来源:LobbyCommands.cs


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