本文整理汇总了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);
}
}