本文整理汇总了C#中GameMessage.fromBytes方法的典型用法代码示例。如果您正苦于以下问题:C# GameMessage.fromBytes方法的具体用法?C# GameMessage.fromBytes怎么用?C# GameMessage.fromBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameMessage
的用法示例。
在下文中一共展示了GameMessage.fromBytes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Disconnect
public void Disconnect()
{
GameMessage msg = new GameMessage();
msg.fromBytes(GameMessage.disconnectMessage(String.Format("Removing Client {0}", idNumber)));
_disconnect(idNumber, msg);
try
{
_socket.Send(GameMessage.disconnectMessage("disconnected by server"));
_socket.Shutdown(SocketShutdown.Both);
_socket.Close(2);
}
catch (Exception se)
{
reportError(se.Message);
}
}
示例2: Receive
void Receive(IAsyncResult result)
{
if (BitConverter.ToUInt16(buffer, 0) == GameMessage.Disconnect)
{
GameMessage msg = new GameMessage();
msg.fromBytes(buffer);
if (disconnect != null)
disconnect(msg);
Die();
}
else
{
if (BitConverter.ToUInt16(buffer, 0) == GameMessage.Initialise)
{
id = BitConverter.ToUInt16(buffer, 2);
}
else
{
GameMessage msg = new GameMessage();
msg.fromBytes(buffer);
if (message != null)
message(msg);
}
if (_socket.Connected)
{
try
{
_socket.BeginReceive(buffer, 0, 8192, SocketFlags.None, new AsyncCallback(Receive), this);
}
catch (Exception se)
{
Error(se.Message);
}
}
}
}
示例3: getMessage
public GameMessage getMessage()
{
newChunk = false;
GameMessage msg = new GameMessage();
msg.fromBytes(buffer);
return msg;
}