本文整理汇总了C#中Lidgren.Network.NetPeer.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C# NetPeer.SendMessage方法的具体用法?C# NetPeer.SendMessage怎么用?C# NetPeer.SendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetPeer
的用法示例。
在下文中一共展示了NetPeer.SendMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkForStatusUpdate
public void checkForStatusUpdate(NetPeer netPeer, NetConnection connection, int team)
{
if (AmountChanged && ((team == Player.Me.Team && timeSinceStatusUpdate >= statusUpdateDelay) || Depleted))
{
timeSinceStatusUpdate = 0f;
AmountChanged = false;
NetOutgoingMessage msg = netPeer.CreateMessage();
msg.Write(MessageID.RESOURCE_STATUS_UPDATE);
msg.Write(ID);
msg.Write((short)Amount);
netPeer.SendMessage(msg, connection, NetDeliveryMethod.ReliableOrdered);
}
}
示例2: CheckForStatusUpdate
public void CheckForStatusUpdate(GameTime gameTime, NetPeer netPeer, NetConnection connection)
{
timeSinceStatusUpdate += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (timeSinceStatusUpdate >= statusUpdateDelay)
{
timeSinceStatusUpdate = 0f;
if (Team == Player.Me.Team)
{
NetOutgoingMessage msg = netPeer.CreateMessage();
msg.Write(MessageID.UNIT_STATUS_UPDATE);
msg.Write(ID);
msg.Write(Team);
msg.Write((short)Hp);
msg.Write(centerPoint.X);
msg.Write(centerPoint.Y);
msg.Write(Rotation);
msg.Write(IsIdle);
// send current command ID, -1 if none
if (Commands.Count > 0)
msg.Write(Commands[0].ID);
else
msg.Write((short)-1);
// send cargoAmount, 0 if not worker
WorkerNublet worker = this as WorkerNublet;
if (worker != null)
msg.Write(worker.CargoAmount);
else
msg.Write((short)0);
netPeer.SendMessage(msg, connection, NetDeliveryMethod.ReliableOrdered);
}
else if (HpChanged)
{
HpChanged = false;
NetOutgoingMessage msg = netPeer.CreateMessage();
msg.Write(MessageID.UNIT_HP_UPDATE);
msg.Write(ID);
msg.Write(Team);
msg.Write((short)Hp);
netPeer.SendMessage(msg, connection, NetDeliveryMethod.ReliableOrdered);
}
}
}
示例3: Send
private void Send(NetPeer peer, NetConnection destination, NetDeliveryMethod method)
{
NetOutgoingMessage nom = peer.CreateMessage(InitialMessageSize());
nom.Write(this.GetType().FullName);
this.WriteData(nom);
peer.SendMessage(nom, destination, method);
}
示例4: SendMessage
public static void SendMessage(NetPeer peer, NetworkMessageType networkMessageType, int data, NetConnection recipient)
{
NetOutgoingMessage message = peer.CreateMessage();
message.Write((byte)networkMessageType);
message.Write(data, 32);
peer.SendMessage(message, recipient, NetDeliveryMethod.ReliableUnordered);
}
示例5: SendMCS
public static void SendMCS()
{
Console.WriteLine("Enter Port: ");
int port = int.Parse(Console.ReadLine());
NetPeerConfiguration config = new NetPeerConfiguration("InduZtry");
config.Port = port;
config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
config.EnableMessageType(NetIncomingMessageType.Data);
//config.EnableUPnP = true;
server = new NetPeer(config);
server.Start();
//Console.WriteLine(server.UPnP.Status);
//server.UPnP.ForwardPort(port, "InduZtry");
//Console.WriteLine(server.UPnP.Status);
//Console.WriteLine("UPnP IP: " + server.UPnP.GetExternalIP());
Thread t = new Thread(RecvMCS);
t.IsBackground = true;
t.Start();
message = "NULL";
while(true) {
Thread.Sleep(10);
if(recipient != null) {
NetOutgoingMessage sendMsg = server.CreateMessage();
sendMsg.Write(message);
server.SendMessage(sendMsg, recipient, NetDeliveryMethod.ReliableOrdered);
}
}
}
示例6: CheckForStatusUpdate
public void CheckForStatusUpdate(GameTime gameTime, NetPeer netPeer, NetConnection connection)
{
timeSinceStatusUpdate += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (HpChanged && timeSinceStatusUpdate >= statusUpdateDelay)
{
timeSinceStatusUpdate = 0f;
HpChanged = false;
NetOutgoingMessage msg = netPeer.CreateMessage();
msg.Write(MessageID.STRUCTURE_STATUS_UPDATE);
msg.Write(ID);
msg.Write(Team);
msg.Write((short)Hp);
netPeer.SendMessage(msg, connection, NetDeliveryMethod.ReliableOrdered);
}
}