本文整理汇总了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);
}
}
示例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();
}
示例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:
//.........这里部分代码省略.........