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


C# ByteBuffer.GetBuffer方法代码示例

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


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

示例1: ProcessFragment

// ReSharper disable UnusedParameter.Local
        private void ProcessFragment(ByteBuffer theData, SFragmentData sFragment, UInt32 type, UInt16 fragment, UInt16 fragmentId, UInt16 fragmentCount)
// ReSharper restore UnusedParameter.Local
        {
            if (sFragment.FragmentId != fragment)
            {
                if (fragment > 0)
                    Console.WriteLine("Dropped fragment: {0} vs {1}", sFragment.FragmentId, fragment);

                sFragment.FragmentId = fragment;
                sFragment.TotalSize = 0;
                sFragment.MapFragments.Clear();
            }

            sFragment.MapFragments.Add(fragmentId, theData);
            sFragment.TotalSize += theData.GetBufferSize();

            if (sFragment.MapFragments.Count == fragmentCount)
            {
                Console.WriteLine("Reassembling fragment {0} ({1} fragments", sFragment.FragmentId, fragmentCount);

                var combined = new ByteBuffer(sFragment.TotalSize);

                var off = 0U;

                for (var i = 0; i < sFragment.MapFragments.Count; ++i)
                {
                    if (!sFragment.MapFragments.ContainsKey(i))
                    {
                        Console.WriteLine("Big error! Fragment doesn't contain a buffer! Fragment: {0} | Index: {1}", fragment, i);
                        return;
                    }

                    var buff = sFragment.MapFragments[i];

                    Array.Copy(buff.GetBuffer(), 0, combined.GetBuffer(), off, buff.GetBufferSize());
                    off += buff.GetBufferSize();
                }

                sFragment.FragmentId = 0;
                sFragment.TotalSize = 0;
                sFragment.MapFragments.Clear();

                HandlePacket(combined);
            }
        }
开发者ID:4ptiv4,项目名称:GenesisSharp,代码行数:46,代码来源:TNLConnection.cs

示例2: byteBuffToString

    private static string byteBuffToString( ByteBuffer byteBuffer )
      {
      if ( byteBuffer == null )
        return "";

      StringBuilder sb = new StringBuilder( 500 );

      int i = 0;
      foreach ( byte b in byteBuffer.GetBuffer() )
        {
        //sb.Append( b.ToString("X2") + "," );
        sb.Append( b.ToString() + "," );

        if ( i % 100 == 0 && i != 0 )
          sb.Append( '\n' );
        i++;
        }

      return sb.ToString();
      }
开发者ID:Georotzen,项目名称:.NET-SDK-1,代码行数:20,代码来源:Log.cs

示例3: HandlePacket

        private void HandlePacket(ByteBuffer buffer)
        {
            var packet = new Packet(buffer.GetBuffer());

            Logger.WriteLog("Incoming Packet: {0}", LogType.Network, packet.Opcode);
            try
            {
                switch (packet.Opcode)
                {
                    // Global
                    case Opcode.LoginRequest:
                        HandleLoginRequest(packet);
                        break;

                    case Opcode.LoginNewCharacter:
                        HandleLoginNewCharacter(packet);
                        break;

                    case Opcode.LoginDeleteCharacter:
                        HandleLoginDeleteCharacter(packet);
                        break;

                    case Opcode.News:
                        HandleNews(packet);
                        break;

                    case Opcode.Login:
                        HandleGlobalLogin(packet);
                        break;

                    case Opcode.Disconnect:
                        HandleDisconnect(packet);
                        break;

                    case Opcode.Chat:
                        ChatManager.HandleChat(this, packet);
                        break;

                    case Opcode.GetFriends:
                        SocialManager.GetFriends(this);
                        break;

                    case Opcode.GetEnemies:
                        SocialManager.GetEnemies(this);
                        break;

                    case Opcode.GetIgnored:
                        SocialManager.GetIgnored(this);
                        break;

                    case Opcode.AddFriend:
                        SocialManager.AddEntry(this, packet, SocialType.Friend);
                        break;

                    case Opcode.AddEnemy:
                        SocialManager.AddEntry(this, packet, SocialType.Enemy);
                        break;

                    case Opcode.AddIgnore:
                        SocialManager.AddEntry(this, packet, SocialType.Ignore);
                        break;

                    case Opcode.RemoveFriend:
                        SocialManager.RemoveEntry(this, packet.ReadPadding(4).ReadLong(), SocialType.Friend);
                        break;

                    case Opcode.RemoveEnemy:
                        SocialManager.RemoveEntry(this, packet.ReadPadding(4).ReadLong(), SocialType.Enemy);
                        break;

                    case Opcode.RemoveIgnore:
                        SocialManager.RemoveEntry(this, packet.ReadPadding(4).ReadLong(), SocialType.Ignore);
                        break;

                    case Opcode.RequestClanInfo:
                        ClanManager.RequestInfo(this);
                        break;

                    case Opcode.ConvoyMissionsRequest:
                        ConvoyManager.MissionsRequest(this);
                        break;

                    // Sector
                    case Opcode.TransferFromGlobal:
                        HandleTransferFromGlobal(packet);
                        break;

                    case Opcode.TransferFromGlobalStage2:
                        HandleTransferFromGlobalStage2(packet);
                        break;

                    case Opcode.TransferFromGlobalStage3:
                        HandleTransferFromGlobalStage3(packet);
                        break;

                    case Opcode.UpdateFirstTimeFlagsRequest:
                        HandleUpdateFirstTimeFlagsRequest(packet);
                        break;

                    case Opcode.Broadcast:
//.........这里部分代码省略.........
开发者ID:4ptiv4,项目名称:GenesisSharp,代码行数:101,代码来源:TNLConnection.cs


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