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


C# NetworkClient.SendChatData方法代码示例

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


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

示例1: DoStep

        public bool DoStep(NetworkClient networkClient, GameClient client)
        {
            DateTime now = DateTime.Now;
            ChatMessage[] outChatMessages = _outChatMessages.Where(cm => cm.MessageTime <= now ).ToArray();

            if (outChatMessages.Length > 0)
            {
                foreach (ChatMessage chatMessage in outChatMessages)
                {
                    _outChatMessages.Remove(chatMessage);

                    //1: From, 2: To, 3: Type, 4: Message
                    string message = Packet.BuildPacket(FromClient.CHAT_MESSAGE,
                        Chat.POST, client.Login, chatMessage.Sender, chatMessage.Type,
                        chatMessage.Message);
                    networkClient.SendChatData(message);

                    //Play notification for private message
                    _soundPlayer.Play();

                    //Out chat message
                    string logMessage = string.Format("[{0}] {1} [{2}] {3}",
                        client.Login,
                        chatMessage.Type == ChatMessageType.Pivate ? "private" : "to",
                        chatMessage.Sender, chatMessage.Message);
                    networkClient.OutChatMessage(logMessage);
                }
                return true;
            }

            return false;
        }
开发者ID:TimeZeroForever,项目名称:TZToolz,代码行数:32,代码来源:GameSystemStep_ChatBot.cs

示例2: DoStep

        public bool DoStep(NetworkClient networkClient, GameClient client)
        {
            int curTickCount = Environment.TickCount;

            //Just started
            if (_prewPingTime == 0)
            {
                _prewPingTime = curTickCount;
                return false;
            }

            if (curTickCount - _prewPingTime >= PING_DELAY_MS)
            {
                //Query params: 0: is a first time ping?, [1]: I1, [2]: ID2, [3]: ID1
                string ping = Packet.BuildPacket(FromClient.PING,
                    _firstTime,
                    client.AdditionalData[ObjectPropertyName.I1][0],
                    client.AdditionalData[ObjectPropertyName.ID2][0],
                    client.AdditionalData[ObjectPropertyName.ID1][0]);
                networkClient.SendData(ping);
                networkClient.SendChatData(ping);

                _firstTime = false;
                _prewPingTime = Environment.TickCount;
                return true;
            }

            return false;
        }
开发者ID:TimeZeroForever,项目名称:TZToolz,代码行数:29,代码来源:GameSystemStep_Ping.cs

示例3: DoStep

        public bool DoStep(NetworkClient networkClient, GameClient client)
        {
            bool chatStarted = false;
            networkClient.OutLogMessage("Starting chat...");

            //Get chat info
            string getInfo = Packet.BuildPacket(FromClient.CHAT_CTRL, Chat.START);
            networkClient.SendData(getInfo);

            //Start chat
            Packet chat = networkClient.InputQueue.Pop(FromServer.CHAT_CTRL);
            if (chat != null)
            {
                string chatServer = chat["@server"];
                string sessionId = (string)client.AdditionalData[ObjectPropertyName.SESSION_ID][0];
                chatStarted = networkClient.StartChat(chatServer, sessionId);
                if (chatStarted)
                {
                    //1: Session ID, 2: Login
                    string chatAuth = Packet.BuildPacket(FromClient.CHAT_CTRL, Chat.AUTH,
                        sessionId, client.Login);
                    networkClient.SendChatData(chatAuth);
                }
            }

            networkClient.OutLogMessage(!chatStarted
                ? "WARNING: chat wasn`t started"
                : "Chat was successfully started");

            return true;
        }
开发者ID:TimeZeroForever,项目名称:TZToolz,代码行数:31,代码来源:LoginStep5_StartChat.cs


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