• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Network.NetOutgoingMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Lidgren.Network.NetOutgoingMessage的典型用法代码示例。如果您正苦于以下问题:C# NetOutgoingMessage类的具体用法?C# NetOutgoingMessage怎么用?C# NetOutgoingMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NetOutgoingMessage类属于Lidgren.Network命名空间,在下文中一共展示了NetOutgoingMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Write

        internal void Write(NetOutgoingMessage Message)
        {
            ChunkCoords.Write(Message);

            Vector3i BlockCoords = ChunkCoords * Size;
            for (int x = 0; x < Size.X; x++) {
                for (int y = 0; y < Size.Y; y++) {
                    for (int z = 0; z < Size.Z; z++) {
                        Vector3i BlockAt = BlockCoords + new Vector3i(x, y, z);

                        if (!Game.World.MapGenerator.Exists(BlockAt / Sector.Size)) {
                            Game.World.MapGenerator.GenerateSector(BlockAt / Sector.Size);
                        }

                        Block Value = Realm.GetBlock(BlockAt);
                        if (Value != null) {
                            Message.Write(true);
                            Value.Write(Message);
                        } else {
                            Message.Write(false);
                        }
                    }
                }
            }
        }
开发者ID:CloneDeath,项目名称:FantasyScape,代码行数:25,代码来源:NetworkChunk.cs


示例2: Encode

 public void Encode(NetOutgoingMessage om)
 {
     om.Write(this.MessageTime);
     om.Write(this.Id);
     om.Write(this.EquipmentPosition);
     om.Write(this.InventoryPosition);
 }
开发者ID:Gothen111,项目名称:2DWorld,代码行数:7,代码来源:CreatureInventoryToEquipmentMessage.cs


示例3: Enqueue

 internal override NetSendResult Enqueue(NetOutgoingMessage message)
 {
     m_queuedSends.Enqueue(message);
     if (m_queuedSends.Count <= GetAllowedSends())
         return NetSendResult.Sent;
     return NetSendResult.Queued;
 }
开发者ID:JamieH,项目名称:lidgren-network-gen3,代码行数:7,代码来源:NetReliableSenderChannel.cs


示例4: Encode

 public void Encode(NetOutgoingMessage om)
 {
     om.Write((int) Value);
        om.Write(Text);
        om.Write(Row);
        om.Write(Col);
 }
开发者ID:kflo,项目名称:Battleship2,代码行数:7,代码来源:AttackResultMessage.cs


示例5: SendMessage

        /// <summary>
        /// Send a message to a specific connection
        /// </summary>
        /// <param name="msg">The message to send</param>
        /// <param name="recipient">The recipient connection</param>
        /// <param name="method">How to deliver the message</param>
        /// <param name="sequenceChannel">Sequence channel within the delivery method</param>
        public NetSendResult SendMessage(NetOutgoingMessage msg, NetConnection recipient, NetDeliveryMethod method, int sequenceChannel)
        {
            if (msg == null)
                throw new ArgumentNullException("msg");
            if (recipient == null)
                throw new ArgumentNullException("recipient");
            if (sequenceChannel >= NetConstants.NetChannelsPerDeliveryMethod)
                throw new ArgumentOutOfRangeException("sequenceChannel");

            NetException.Assert(
                ((method != NetDeliveryMethod.Unreliable && method != NetDeliveryMethod.ReliableUnordered) ||
                ((method == NetDeliveryMethod.Unreliable || method == NetDeliveryMethod.ReliableUnordered) && sequenceChannel == 0)),
                "Delivery method " + method + " cannot use sequence channels other than 0!"
            );

            NetException.Assert(method != NetDeliveryMethod.Unknown, "Bad delivery method!");

            if (msg.m_isSent)
                throw new NetException("This message has already been sent! Use NetPeer.SendMessage() to send to multiple recipients efficiently");
            msg.m_isSent = true;

            int len = NetConstants.UnfragmentedMessageHeaderSize + msg.LengthBytes; // headers + length, faster than calling msg.GetEncodedSize
            if (len <= recipient.m_currentMTU)
            {
                Interlocked.Increment(ref msg.m_recyclingCount);
                return recipient.EnqueueMessage(msg, method, sequenceChannel);
            }
            else
            {
                // message must be fragmented!
                SendFragmentedMessage(msg, new NetConnection[] { recipient }, method, sequenceChannel);
                return NetSendResult.Queued; // could be different for each connection; Queued is "most true"
            }
        }
开发者ID:ncoder,项目名称:MonoGame,代码行数:41,代码来源:NetPeer.Send.cs


示例6: SerializeStream

 private void SerializeStream(NetOutgoingMessage netOutgoingMessage)
 {
     //send our position to the server
     //this should only be happening on an object that is ours
     _serializer.vector3 = transform.position;
     _serializer.OnSerialize(netOutgoingMessage);
 }
开发者ID:traleven,项目名称:PNet,代码行数:7,代码来源:NetPlayer.cs


示例7: SendMessage

 public override void SendMessage(NetOutgoingMessage message)
 {
     for (int i = 0; i < connections.Count; ++i)
     {
         SendMessage(message, connections[i]);
     }
 }
开发者ID:bbqchickenrobot,项目名称:atomic-bomberman-xna,代码行数:7,代码来源:Server.cs


示例8: WriteData

 protected override void WriteData(NetOutgoingMessage Message)
 {
     texture.Write(Message);
     byte[] data = GetBytes(texture.Texture);
     Message.Write((Int32)data.Length);
     Message.Write(data);
 }
开发者ID:CloneDeath,项目名称:FantasyScape,代码行数:7,代码来源:UpdateTexture.cs


示例9: Encode

 public void Encode(NetOutgoingMessage om)
 {
     om.Write(this.Id);
     om.Write(this.MessageTime);
     om.Write(this.Health);
     om.Write(this.MaxHealth);
 }
开发者ID:Gothen111,项目名称:2DWorld,代码行数:7,代码来源:UpdateObjectHealthMessage.cs


示例10: W

 public void W(NetOutgoingMessage om)
 {
     om.Write(Uid);
     om.Write(X);
     om.Write(Y);
     om.Write(SpriteId);
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:7,代码来源:Msg_HappyPlayerLoginRsp.cs


示例11: SendFragmentedMessage

		// on user thread
		private NetSendResult SendFragmentedMessage(NetOutgoingMessage msg, IList<NetConnection> recipients, NetDeliveryMethod method, int sequenceChannel)
		{
			// Note: this group id is PER SENDING/NetPeer; ie. same id is sent to all recipients;
			// this should be ok however; as long as recipients differentiate between same id but different sender
			int group = Interlocked.Increment(ref m_lastUsedFragmentGroup);
			if (group >= NetConstants.MaxFragmentationGroups)
			{
				// @TODO: not thread safe; but in practice probably not an issue
				m_lastUsedFragmentGroup = 1;
				group = 1;
			}
			msg.m_fragmentGroup = group;

			// do not send msg; but set fragmentgroup in case user tries to recycle it immediately

			// create fragmentation specifics
			int totalBytes = msg.LengthBytes;

			// determine minimum mtu for all recipients
			int mtu = GetMTU(recipients);
			int bytesPerChunk = NetFragmentationHelper.GetBestChunkSize(group, totalBytes, mtu);

			int numChunks = totalBytes / bytesPerChunk;
			if (numChunks * bytesPerChunk < totalBytes)
				numChunks++;

			NetSendResult retval = NetSendResult.Sent;

			int bitsPerChunk = bytesPerChunk * 8;
			int bitsLeft = msg.LengthBits;
			for (int i = 0; i < numChunks; i++)
			{
				NetOutgoingMessage chunk = CreateMessage(0);

				chunk.m_bitLength = (bitsLeft > bitsPerChunk ? bitsPerChunk : bitsLeft);
				chunk.m_data = msg.m_data;
				chunk.m_fragmentGroup = group;
				chunk.m_fragmentGroupTotalBits = totalBytes * 8;
				chunk.m_fragmentChunkByteSize = bytesPerChunk;
				chunk.m_fragmentChunkNumber = i;

				NetException.Assert(chunk.m_bitLength != 0);
				NetException.Assert(chunk.GetEncodedSize() < mtu);

				Interlocked.Add(ref chunk.m_recyclingCount, recipients.Count);

				foreach (NetConnection recipient in recipients)
				{
					var res = recipient.EnqueueMessage(chunk, method, sequenceChannel);
					if (res == NetSendResult.Dropped)
						Interlocked.Decrement(ref chunk.m_recyclingCount);
					if ((int)res > (int)retval)
						retval = res; // return "worst" result
				}

				bitsLeft -= bitsPerChunk;
			}

			return retval;
		}
开发者ID:Aslan125,项目名称:GameNet,代码行数:61,代码来源:NetPeer.Fragmentation.cs


示例12: SendMessage

 public void SendMessage(NetOutgoingMessage msg)
 {
     if (InnerClient.Status == NetPeerStatus.Running)
     {
         InnerClient.SendMessage(msg, NetDeliveryMethod.Unreliable);
     }
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:7,代码来源:CozyClient.Main.cs


示例13: WriteType

 public void WriteType(NetOutgoingMessage Message, AttributeTypeID Type, object Data)
 {
     switch (Type) {
         case AttributeTypeID.Float:
             Message.Write((float)Data);
             break;
         case AttributeTypeID.Int:
             Message.Write((int)Data);
             break;
         case AttributeTypeID.List:
             Console.WriteLine("Engine unable to serialize list objects");
             break;
         case AttributeTypeID.Long:
             Message.Write((long)Data);
             break;
         case AttributeTypeID.Rectangle:
             Message.WriteRectangle((Rectangle)Data);
             break;
         case AttributeTypeID.String:
             Message.Write((string)Data);
             break;
         case AttributeTypeID.Vector2:
             Message.WriteVector2((Vector2)Data);
             break;
         case AttributeTypeID.Bool:
             Message.Write((bool)Data);
             break;
         default:
             Console.WriteLine("AttributeSystem Unrecognised Type In AttributeSystem Type: {0}", Type.ToString());
             break;
     }
 }
开发者ID:fusspawn,项目名称:sobriety,代码行数:32,代码来源:Attribute.cs


示例14: CreateOutgoingMessage

        public static OutgoingMessage CreateOutgoingMessage(int opcode, byte[] data, NetOutgoingMessage packet)
        {
            OutgoingMessage com = CreateOutgoingMessage(opcode, data);
            com.EncodeTo(packet);

            return com;
        }
开发者ID:bberak,项目名称:PokerDotNet,代码行数:7,代码来源:MessageFormatter.cs


示例15: Encode

 public void Encode(NetOutgoingMessage om)
 {
     om.Write(Shots);
        om.Write(Hits);
        om.Write(Misses);
        om.Write(ShipsKilled);
 }
开发者ID:kflo,项目名称:Battleship2,代码行数:7,代码来源:playerStatsMessage.cs


示例16: OnSerialize

 /// <summary>
 /// write to the message
 /// </summary>
 /// <param name="message">message to write to</param>
 public void OnSerialize(NetOutgoingMessage message)
 {
     message.Write(X);
     message.Write(Y);
     message.Write(Z);
     message.Write(W);
 }
开发者ID:traleven,项目名称:PNet,代码行数:11,代码来源:SerializedStructs.cs


示例17: Write

 public override void Write(NetOutgoingMessage msg)
 {
     msg.Write(Id);
     msg.Write(Cards.Count);
     foreach(string value in Cards)
         msg.Write(value);
 }
开发者ID:DatZach,项目名称:HumanityAgainstCards,代码行数:7,代码来源:WinnerPicked.cs


示例18: Encode

 public void Encode(NetOutgoingMessage om)
 {
     om.Write(this.BlockID);
     om.Write(this.X);
     om.Write(this.Y);
     om.Write(this.Z);
 }
开发者ID:Express50,项目名称:Bricklayer,代码行数:7,代码来源:BlockMessage.cs


示例19: WriteParams

 /// <summary>
 /// write all the serializing objects to the stream
 /// </summary>
 /// <param name="msg"></param>
 /// <param name="towrite"></param>
 public static void WriteParams(ref NetOutgoingMessage msg, INetSerializable[] towrite)
 {
     foreach (var arg in towrite)
     {
         arg.OnSerialize(msg);
     }
 }
开发者ID:traleven,项目名称:PNet,代码行数:12,代码来源:RPCUtils.cs


示例20: ToNetBuffer

        /// <summary>
        /// Converts the packet into an outgoing packet
        /// </summary>
        /// <returns>Returns the specified IPacket as a packet</returns>
        public virtual NetOutgoingMessage ToNetBuffer(ref NetOutgoingMessage netOutgoingMessage)
        {
            //TODO: Find a way to write the packet header given the HashCode of the class name...
            netOutgoingMessage.Write(GlobalPacketMap.PacketCache[GetType()]);

            return null;
        }
开发者ID:hilts-vaughan,项目名称:inspire,代码行数:11,代码来源:Packet.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Network.NetPeer类代码示例发布时间:2022-05-26
下一篇:
C# Network.NetIncomingMessage类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap