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


C# NetIncomingMessage.Clone方法代码示例

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


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

示例1: BufferField

 internal void BufferField(NetIncomingMessage msg, byte fieldId)
 {
     var toBuffer = new NetBuffer();
     msg.Clone(toBuffer);
     fieldBuffer[fieldId] = toBuffer;
 }
开发者ID:traleven,项目名称:PNet,代码行数:6,代码来源:NetworkView.cs

示例2: Consume

        private static void Consume(NetIncomingMessage msg)
        {
            try
            {
                //faster than switch, as this is in most to least common order
                if (msg.SequenceChannel == Channels.UNRELIABLE_STREAM)
                {
                    var actorId = msg.ReadUInt16();
                    NetworkView find;
                    if (NetworkView.Find(actorId, out find))
                    {
                        Player player = GetPlayer(msg.SenderConnection);
                        find.OnDeserializeStream(msg, player);
                    }
                }
                else if (msg.SequenceChannel == Channels.RELIABLE_STREAM)
                {
                    var actorId = msg.ReadUInt16();
                    NetworkView find;
                    if (NetworkView.Find(actorId, out find))
                    {
                        Player player = GetPlayer(msg.SenderConnection);
                        find.OnDeserializeStream(msg, player);
                    }
                }
                else if (msg.SequenceChannel >= Channels.BEGIN_RPCMODES && msg.SequenceChannel <= Channels.OWNER_RPC)
                {
                    //rpc...
                    var viewID = msg.ReadUInt16();
                    var rpcId = msg.ReadByte();
                    Player player = GetPlayer(msg.SenderConnection);
                    NetworkView find;
                    var info = new NetMessageInfo((RPCMode)(msg.SequenceChannel - Channels.BEGIN_RPCMODES), player);
                    if (NetworkView.Find(viewID, out find))
                    {
                        find.CallRPC(rpcId, msg, info);

                        //Do we need to forward this still?
                        if (info.mode != RPCMode.Server && info.continueForwarding)
                        {
                            //need to forward...
                            if (info.mode == RPCMode.Others || info.mode == RPCMode.All) { }
                            else
                            {
                                find.Buffer(msg);
                            }
                            find.Send(msg, info.mode, msg.SenderConnection);
                        }
                    }

                }
                else if (msg.SequenceChannel == Channels.SYNCHED_FIELD)
                {
                    var viewId = msg.ReadUInt16();
                    var fieldId = msg.ReadByte();
                    NetworkView find;
                    if (NetworkView.Find(viewId, out find))
                    {
                        find.BufferField(msg, fieldId);
                        find.SendField(msg, msg.SenderConnection);
                    }
                }
                else if (msg.SequenceChannel == Channels.OBJECT_RPC)
                {
                    Player player = GetPlayer(msg.SenderConnection);
                    if (player.CurrentRoom != null)
                        player.CurrentRoom.IncomingObjectRPC(msg);
                }
                else if (msg.SequenceChannel == Channels.STATIC_RPC)
                {
                    var rpcId = msg.ReadByte();

                    var player = GetPlayer(msg.SenderConnection);
                    var currentRoom = player.CurrentRoom;
                    if (currentRoom != null)
                    {
                        NetMessageInfo info = new NetMessageInfo(RPCMode.None, player);
                        currentRoom.CallRPC(rpcId, msg, info);

                        if (info.continueForwarding)
                        {
                            var newMessage = peer.CreateMessage();
                            msg.Clone(newMessage);
                            currentRoom.SendMessage(newMessage);
                        }
                    }

                }
                else if (msg.SequenceChannel == Channels.STATIC_UTILS)
                {
                    ProcessUtils(msg);
                }
                else
                {
                    Debug.LogWarning("data received over unhandled channel " + msg.SequenceChannel);
                }
            }
            catch (Exception ex)
            {
                Debug.Log("[Consumption] {0} : {1}", ex.Message, ex.StackTrace);
//.........这里部分代码省略.........
开发者ID:Antaresgames,项目名称:PNet,代码行数:101,代码来源:PNetServer.cs

示例3: HandleStaticRpc

        static void HandleStaticRpc(NetIncomingMessage msg)
        {
            var rpcId = msg.ReadByte();

            var player = GetPlayer(msg.SenderConnection);
            var currentRoom = player.CurrentRoom;
            if (currentRoom != null)
            {
                var info = new NetMessageInfo(RPCMode.None, player);
                currentRoom.CallRPC(rpcId, msg, info);

                if (info.continueForwarding)
                {
                    var newMessage = peer.CreateMessage();
                    msg.Clone(newMessage);
                    if (msg.DeliveryMethod == NetDeliveryMethod.ReliableOrdered)
                        currentRoom.SendMessage(newMessage, true);
                    else
                        currentRoom.SendMessage(newMessage, false);
                }
            }
            else
            {
                Debug.LogWarning("[PNetS.Consume] Player {0} attempted static rpc {1}, but they are not in a room to do so",
                    player, rpcId);
                (player).InternalErrorCount++;
            }
        }
开发者ID:traleven,项目名称:PNet,代码行数:28,代码来源:PNetServer.cs


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