當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。