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


C# ServerMessage.DecodeMessage方法代码示例

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


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

示例1: Update

        private void Update()
        {
            while (this.m_netClient.Status == NetPeerStatus.Running && this.m_updateThread.ThreadState == ThreadState.Running)
            {
                NetIncomingMessage netIncomingMessage;

                while ((netIncomingMessage = this.m_netClient.ReadMessage()) != null)
                {
                    switch (netIncomingMessage.MessageType)
                    {
                        //case NetIncomingMessageType.VerboseDebugMessage:
                        //case NetIncomingMessageType.DebugMessage:
                        case NetIncomingMessageType.WarningMessage:
                        case NetIncomingMessageType.ErrorMessage:
                            {
                                MessageBox.Show(netIncomingMessage.ReadString());
                                break;
                            }
                        case NetIncomingMessageType.UnconnectedData:
                            {
                                switch ((ServerMessageTypes)netIncomingMessage.ReadByte())
                                {
                                    case ServerMessageTypes.RequestHostList:
                                        {
                                            ServerMessage serverMessage = new ServerMessage();
                                            serverMessage.DecodeMessage(netIncomingMessage);

                                            if (this.m_serverInfo.ContainsKey(serverMessage.ID) == false)
                                            {
                                                this.m_serverInfo.Add(serverMessage.ID, serverMessage);
                                            }
                                            else
                                            {
                                                this.m_serverInfo[serverMessage.ID].Hostname = serverMessage.Hostname;
                                                this.m_serverInfo[serverMessage.ID].Players = serverMessage.Players;
                                                this.m_serverInfo[serverMessage.ID].MaximumPlayers = serverMessage.MaximumPlayers;
                                                this.m_serverInfo[serverMessage.ID].LastMessageSendTime = serverMessage.LastMessageSendTime;
                                            }

                                            break;
                                        }
                                    case ServerMessageTypes.RequestPing:
                                        {
                                            long ServerID = netIncomingMessage.ReadInt64();

                                            this.m_serverInfo[ServerID].Ping = Convert.ToInt32((0.25 * this.m_serverInfo[ServerID].Ping) + ((1 - 0.25) * (netIncomingMessage.ReceiveTime - this.m_serverInfo[ServerID].LastMessageSendTime)));
                                            break;
                                        }
                                }
                                break;
                            }
                    }

                    this.m_netClient.Recycle(netIncomingMessage);
                }

                Thread.Sleep(1);
            }
        }
开发者ID:WopsS,项目名称:L.O.G,代码行数:59,代码来源:Network.cs


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