本文整理匯總了C#中OpenSim.Region.ClientStack.LindenUDP.OutgoingPacket.Destroy方法的典型用法代碼示例。如果您正苦於以下問題:C# OutgoingPacket.Destroy方法的具體用法?C# OutgoingPacket.Destroy怎麽用?C# OutgoingPacket.Destroy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OpenSim.Region.ClientStack.LindenUDP.OutgoingPacket
的用法示例。
在下文中一共展示了OutgoingPacket.Destroy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SendPacketFinal
/// <summary>
/// Actually send a packet to a client.
/// </summary>
/// <param name = "outgoingPacket"></param>
internal void SendPacketFinal(OutgoingPacket outgoingPacket)
{
UDPPacketBuffer buffer = outgoingPacket.Buffer;
byte flags = buffer.Data[0];
bool isResend = (flags & Helpers.MSG_RESENT) != 0;
bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0;
bool isZerocoded = (flags & Helpers.MSG_ZEROCODED) != 0;
LLUDPClient udpClient = outgoingPacket.Client;
if (!udpClient.IsConnected)
return;
#region ACK Appending
int dataLength = buffer.DataLength;
// NOTE: I'm seeing problems with some viewers when ACKs are appended to zerocoded packets so I've disabled that here
if (!isZerocoded)
{
// Keep appending ACKs until there is no room left in the buffer or there are
// no more ACKs to append
uint ackCount = 0;
uint ack;
while (dataLength + 5 < buffer.Data.Length && udpClient.PendingAcks.Dequeue(out ack))
{
Utils.UIntToBytesBig(ack, buffer.Data, dataLength);
dataLength += 4;
++ackCount;
}
if (ackCount > 0)
{
// Set the last byte of the packet equal to the number of appended ACKs
buffer.Data[dataLength++] = (byte) ackCount;
// Set the appended ACKs flag on this packet
buffer.Data[0] = (byte) (buffer.Data[0] | Helpers.MSG_APPENDED_ACKS);
}
}
buffer.DataLength = dataLength;
#endregion ACK Appending
#region Sequence Number Assignment
bool canBeRemoved = false;
if (!isResend)
{
// Not a resend, assign a new sequence number
uint sequenceNumber = (uint) Interlocked.Increment(ref udpClient.CurrentSequence);
Utils.UIntToBytesBig(sequenceNumber, buffer.Data, 1);
outgoingPacket.SequenceNumber = sequenceNumber;
if (isReliable)
{
// Add this packet to the list of ACK responses we are waiting on from the server
udpClient.NeedAcks.Add(outgoingPacket);
Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength);
}
else
canBeRemoved = true;
}
#endregion Sequence Number Assignment
// Stats tracking
Interlocked.Increment(ref udpClient.PacketsSent);
// if (isReliable)
// Interlocked.Add(ref udpClient.UnackedBytes, outgoingPacket.Buffer.DataLength);
// Put the UDP payload on the wire
// AsyncBeginSend(buffer);
SyncSend(buffer);
// Keep track of when this packet was sent out (right now)
outgoingPacket.TickCount = Environment.TickCount & Int32.MaxValue;
if (outgoingPacket.FinishedMethod != null)
outgoingPacket.FinishedMethod(outgoingPacket);
if (canBeRemoved)
outgoingPacket.Destroy(1);
}