本文整理汇总了C#中PacketAckPacket类的典型用法代码示例。如果您正苦于以下问题:C# PacketAckPacket类的具体用法?C# PacketAckPacket怎么用?C# PacketAckPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PacketAckPacket类属于命名空间,在下文中一共展示了PacketAckPacket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SpoofAck
// SpoofAck: create an ACK for the given packet
public Packet SpoofAck(uint sequence)
{
PacketAckPacket spoof = new PacketAckPacket();
spoof.Packets = new PacketAckPacket.PacketsBlock[1];
spoof.Packets[0] = new PacketAckPacket.PacketsBlock();
spoof.Packets[0].ID = sequence;
return (Packet)spoof;
//Legacy:
////Hashtable blocks = new Hashtable();
////Hashtable fields = new Hashtable();
////fields["ID"] = (uint)sequence;
////blocks[fields] = "Packets";
////return .BuildPacket("PacketAck", proxyConfig.protocol, blocks, Helpers.MSG_ZEROCODED);
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:15,代码来源:GridProxy.cs
示例2: CheckAcks
// CheckAcks: check for and remove ACKs of packets we've injected
public Packet CheckAcks(Packet packet, Direction direction, ref int length, ref bool needsCopy)
{
Dictionary<uint, Packet> acks = direction == Direction.Incoming ? outgoingAcks : incomingAcks;
List<uint> seenAcks = direction == Direction.Incoming ? outgoingSeenAcks : incomingSeenAcks;
if (acks.Count == 0)
return packet;
// check for embedded ACKs
if (packet.Type == PacketType.PacketAck)
{
bool changed = false;
List<PacketAckPacket.PacketsBlock> newPacketBlocks = new List<PacketAckPacket.PacketsBlock>();
foreach (PacketAckPacket.PacketsBlock pb in ((PacketAckPacket)packet).Packets)
{
uint id = pb.ID;
#if DEBUG_SEQUENCE
string hrup = "Check !" + id;
#endif
if (acks.ContainsKey(id))
{
#if DEBUG_SEQUENCE
hrup += " get's";
#endif
acks.Remove(id);
seenAcks.Add(id);
changed = true;
}
else
newPacketBlocks.Add(pb);
#if DEBUG_SEQUENCE
Console.WriteLine(hrup);
#endif
}
if (changed)
{
PacketAckPacket newPacket = new PacketAckPacket();
newPacket.Packets = new PacketAckPacket.PacketsBlock[newPacketBlocks.Count];
int a = 0;
foreach (PacketAckPacket.PacketsBlock pb in newPacketBlocks)
{
newPacket.Packets[a++] = pb;
}
SwapPacket(packet, (Packet)newPacket);
packet = newPacket;
length = packet.Header.Data.Length;
needsCopy = false;
}
}
// check for appended ACKs
if ((packet.Header.Data[0] & Helpers.MSG_APPENDED_ACKS) != 0)
{
int ackCount = packet.Header.AckList.Length;
for (int i = 0; i < ackCount; )
{
uint ackID = packet.Header.AckList[i]; // FIXME FIXME FIXME
#if DEBUG_SEQUENCE
string hrup = "Check @" + ackID;
#endif
if (acks.ContainsKey(ackID))
{
#if DEBUG_SEQUENCE
hrup += " get's";
#endif
uint[] newAcks = new uint[ackCount - 1];
Array.Copy(packet.Header.AckList, 0, newAcks, 0, i);
Array.Copy(packet.Header.AckList, i + 1, newAcks, i, ackCount - i - 1);
packet.Header.AckList = newAcks;
--ackCount;
acks.Remove(ackID);
seenAcks.Add(ackID);
needsCopy = false;
}
else
++i;
#if DEBUG_SEQUENCE
Console.WriteLine(hrup);
#endif
}
if (ackCount == 0)
{
packet.Header.Flags ^= Helpers.MSG_APPENDED_ACKS;
packet.Header.AckList = new uint[0];
}
}
return packet;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:92,代码来源:GridProxy.cs
示例3: SendAckImmediate
public virtual void SendAckImmediate(IPEndPoint remoteEndpoint, PacketAckPacket ack)
{
byte[] packetData = ack.ToBytes();
int length = packetData.Length;
UDPPacketBuffer buffer = new UDPPacketBuffer(remoteEndpoint, length);
buffer.DataLength = length;
Buffer.BlockCopy(packetData, 0, buffer.Data, 0, length);
AsyncBeginSend(buffer);
}
开发者ID:JeffCost,项目名称:opensim,代码行数:12,代码来源:LLUDPServer.cs
示例4: SendAck
public void SendAck(uint ack)
{
PacketAckPacket acks = new PacketAckPacket();
acks.Header.Reliable = false;
acks.Packets = new PacketAckPacket.PacketsBlock[1];
acks.Packets[0] = new PacketAckPacket.PacketsBlock();
acks.Packets[0].ID = ack;
SendPacket(acks, true);
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:10,代码来源:Agent.cs
示例5: SeparateAck
// SeparateAck: create a standalone PacketAck for packet's appended ACKs
public Packet SeparateAck(Packet packet)
{
PacketAckPacket seperate = new PacketAckPacket();
seperate.Packets = new PacketAckPacket.PacketsBlock[packet.Header.AckList.Length];
for (int i = 0; i < packet.Header.AckList.Length; ++i)
{
seperate.Packets[i] = new PacketAckPacket.PacketsBlock();
seperate.Packets[i].ID = packet.Header.AckList[i];
}
Packet ack = seperate;
ack.Header.Sequence = packet.Header.Sequence;
return ack;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:16,代码来源:GridProxy.cs
示例6: SendAcks
public void SendAcks(LLUDPClient udpClient)
{
uint ack;
if (udpClient.PendingAcks.Dequeue(out ack))
{
List<PacketAckPacket.PacketsBlock> blocks = new List<PacketAckPacket.PacketsBlock>();
PacketAckPacket.PacketsBlock block = new PacketAckPacket.PacketsBlock();
block.ID = ack;
blocks.Add(block);
while (udpClient.PendingAcks.Dequeue(out ack))
{
block = new PacketAckPacket.PacketsBlock();
block.ID = ack;
blocks.Add(block);
}
PacketAckPacket packet = new PacketAckPacket();
packet.Header.Reliable = false;
packet.Packets = blocks.ToArray();
SendPacket(udpClient, packet, ThrottleOutPacketType.Unknown, true, null);
}
}
开发者ID:JeffCost,项目名称:opensim,代码行数:25,代码来源:LLUDPServer.cs
示例7: SendAcks
public void SendAcks(LLAgent agent)
{
const int MAX_ACKS_PER_PACKET = Byte.MaxValue;
uint ack;
if (agent.PendingAcks.TryDequeue(out ack))
{
List<PacketAckPacket.PacketsBlock> blocks = new List<PacketAckPacket.PacketsBlock>(agent.PendingAcks.Count);
PacketAckPacket.PacketsBlock block = new PacketAckPacket.PacketsBlock();
block.ID = ack;
blocks.Add(block);
int count = 1;
while (count < MAX_ACKS_PER_PACKET && agent.PendingAcks.TryDequeue(out ack))
{
block = new PacketAckPacket.PacketsBlock();
block.ID = ack;
blocks.Add(block);
++count;
}
PacketAckPacket packet = new PacketAckPacket();
packet.Header.Reliable = false;
packet.Packets = blocks.ToArray();
SendPacket(agent, packet, ThrottleCategory.Unknown, false);
}
}
开发者ID:thoys,项目名称:simian,代码行数:30,代码来源:LLUDPServer.cs
示例8: SendAckImmediate
private void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber)
{
PacketAckPacket ack = new PacketAckPacket();
ack.Header.Reliable = false;
ack.Packets = new PacketAckPacket.PacketsBlock[1];
ack.Packets[0] = new PacketAckPacket.PacketsBlock();
ack.Packets[0].ID = sequenceNumber;
byte[] packetData = ack.ToBytes();
int length = packetData.Length;
UDPPacketBuffer buffer = new UDPPacketBuffer(remoteEndpoint, length);
buffer.DataLength = length;
Buffer.BlockCopy(packetData, 0, buffer.Data, 0, length);
// AsyncBeginSend(buffer);
SyncSend(buffer);
}
开发者ID:HGExchange,项目名称:Aurora-Sim,代码行数:20,代码来源:LLUDPServer.cs
示例9: SendAckImmediate
private void SendAckImmediate(IPEndPoint remoteEndpoint, uint sequenceNumber)
{
PacketAckPacket ack = new PacketAckPacket();
ack.Header.Reliable = false;
ack.Packets = new PacketAckPacket.PacketsBlock[1];
ack.Packets[0] = new PacketAckPacket.PacketsBlock();
ack.Packets[0].ID = sequenceNumber;
byte[] packetData = ack.ToBytes();
int length = packetData.Length;
OutgoingPacket outgoingPacket = new OutgoingPacket(null, packetData, 0, length,
remoteEndpoint, false, PacketType.PacketAck);
AsyncBeginSend(outgoingPacket);
}
开发者ID:digitalmystic,项目名称:halcyon,代码行数:16,代码来源:LLUDPServer.cs
示例10: SendACK
private void SendACK(uint id)
{
try
{
PacketAckPacket ack = new PacketAckPacket();
ack.Packets = new PacketAckPacket.PacketsBlock[1];
ack.Packets[0].ID = id;
ack.Header.Reliable = false;
// Set the sequence number
ack.Header.Sequence = ++Sequence;
Listener.SendTo(ack.ToBytes(), RemoteEndpoint);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
开发者ID:BackupTheBerlios,项目名称:libsecondlife-svn,代码行数:20,代码来源:DebugServer.cs
示例11: SeparateAck
// SeparateAck: create a standalone PacketAck for packet's appended ACKs
public Packet SeparateAck(Packet packet)
{
PacketAckPacket seperate = new PacketAckPacket();
int ackCount = ((packet.Header.Data[0] & Helpers.MSG_APPENDED_ACKS) == 0 ? 0 : (int)packet.Header.Data[packet.Header.Data.Length - 1]);
seperate.Packets = new PacketAckPacket.PacketsBlock[ackCount];
for (int i = 0; i < ackCount; ++i)
{
int offset = packet.Header.Data.Length - (ackCount - i) * 4 - 1;
seperate.Packets[i].ID = (uint) ((packet.Header.Data[offset++] << 0)
+ (packet.Header.Data[offset++] << 8)
+ (packet.Header.Data[offset++] << 16)
+ (packet.Header.Data[offset++] << 24))
;
}
Packet ack = (Packet)seperate;
ack.Header.Sequence = packet.Header.Sequence;
return ack;
}
开发者ID:BackupTheBerlios,项目名称:libsecondlife-svn,代码行数:21,代码来源:SLProxy.cs
示例12: SendAcks
/// <summary>
/// Sends out pending acknowledgements
/// </summary>
private void SendAcks(NetworkInfo User_info)
{
lock (User_info.PendingAcks)
{
if (connected && User_info.PendingAcks.Count > 0)
{
if (User_info.PendingAcks.Count > 250)
{
// FIXME: Handle the odd case where we have too many pending ACKs queued up
//Client.Log("Too many ACKs queued up!", Helpers.LogLevel.Error);
return;
}
int i = 0;
PacketAckPacket acks = new PacketAckPacket();
acks.Packets = new PacketAckPacket.PacketsBlock[User_info.PendingAcks.Count];
foreach (uint ack in User_info.PendingAcks.Values)
{
acks.Packets[i] = new PacketAckPacket.PacketsBlock();
acks.Packets[i].ID = ack;
i++;
}
acks.Header.Reliable = false;
SendPacket(acks, true,User_info);
User_info.PendingAcks.Clear();
}
}
}
开发者ID:BackupTheBerlios,项目名称:ulife-svn,代码行数:34,代码来源:ViewerServer.cs
示例13: SendAcks
void SendAcks()
{
PacketAckPacket acks = null;
lock (pendingAcks)
{
if (pendingAcks.Count > 0)
{
if (pendingAcks.Count > 250)
{
Logger.Log("Too many ACKs queued up!", Helpers.LogLevel.Error);
return;
}
acks = new PacketAckPacket();
acks.Header.Reliable = false;
acks.Packets = new PacketAckPacket.PacketsBlock[pendingAcks.Count];
for (int i = 0; i < pendingAcks.Count; i++)
{
acks.Packets[i] = new PacketAckPacket.PacketsBlock();
acks.Packets[i].ID = pendingAcks.Values[i];
}
pendingAcks.Clear();
}
}
if (acks != null)
SendPacket(acks, true);
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:31,代码来源:Agent.cs
示例14: ack_pack
private void ack_pack(Packet Pack)
{
if (Pack.Header.Reliable)
{
libsecondlife.Packets.PacketAckPacket ack_it = new PacketAckPacket();
ack_it.Packets = new PacketAckPacket.PacketsBlock[1];
ack_it.Packets[0] = new PacketAckPacket.PacketsBlock();
ack_it.Packets[0].ID = Pack.Header.Sequence;
ack_it.Header.Reliable = false;
OutPacket(ack_it);
}
/*
if (Pack.Header.Reliable)
{
lock (PendingAcks)
{
uint sequence = (uint)Pack.Header.Sequence;
if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; }
}
}*/
}
开发者ID:BackupTheBerlios,项目名称:ulife-svn,代码行数:23,代码来源:SimClient.cs
示例15: SendAcks
/// <summary>
/// Sends out pending acknowledgements
/// </summary>
private void SendAcks()
{
lock (PendingAcks)
{
if (PendingAcks.Count > 0)
{
if (PendingAcks.Count > 250)
{
Logger.Log("Too many ACKs queued up!", Helpers.LogLevel.Error, Client);
return;
}
PacketAckPacket acks = new PacketAckPacket();
acks.Header.Reliable = false;
acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count];
for (int i = 0; i < PendingAcks.Count; i++)
{
acks.Packets[i] = new PacketAckPacket.PacketsBlock();
acks.Packets[i].ID = PendingAcks.Values[i];
}
SendPacket(acks, true);
PendingAcks.Clear();
}
}
}
开发者ID:jhs,项目名称:libopenmetaverse,代码行数:31,代码来源:Simulator.cs
示例16: SendAcks
private void SendAcks()
{
lock (PendingAcks)
{
if (PendingAcks.Count > 0)
{
if (PendingAcks.Count > 250)
{
// FIXME: Handle the odd case where we have too many pending ACKs queued up
OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Too many ACKs queued up!");
return;
}
//OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Sending PacketAck");
int i = 0;
PacketAckPacket acks = new PacketAckPacket();
acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count];
foreach (uint ack in PendingAcks.Values)
{
acks.Packets[i] = new PacketAckPacket.PacketsBlock();
acks.Packets[i].ID = ack;
i++;
}
acks.Header.Reliable = false;
OutPacket(acks);
PendingAcks.Clear();
}
}
}
开发者ID:BackupTheBerlios,项目名称:ulife-svn,代码行数:33,代码来源:SimClient.cs
示例17: SendAck
private void SendAck(ushort id)
{
PacketAckPacket ack = new PacketAckPacket();
ack.Packets = new PacketAckPacket.PacketsBlock[1];
ack.Packets[0] = new PacketAckPacket.PacketsBlock();
ack.Packets[0].ID = id;
ack.Header.Reliable = false;
lock (PendingAcks)
{
if (PendingAcks.Contains(id))
{
PendingAcks.Remove(id);
}
}
SendPacket(ack, true);
}
开发者ID:BackupTheBerlios,项目名称:libsecondlife-svn,代码行数:19,代码来源:NetworkManager.cs
示例18: CheckAcks
// CheckAcks: check for and remove ACKs of packets we've injected
public Packet CheckAcks(Packet packet, Direction direction, ref int length, ref bool needsCopy)
{
Dictionary<uint, Packet> acks = direction == Direction.Incoming ? outgoingAcks : incomingAcks;
List<uint> seenAcks = direction == Direction.Incoming ? outgoingSeenAcks : incomingSeenAcks;
if (acks.Count == 0)
return packet;
// check for embedded ACKs
if (packet.Type == PacketType.PacketAck)
{
bool changed = false;
List<PacketAckPacket.PacketsBlock> newPacketBlocks = new List<PacketAckPacket.PacketsBlock>();
foreach (PacketAckPacket.PacketsBlock pb in ((PacketAckPacket)packet).Packets)
{
uint id = pb.ID;
if (acks.ContainsKey(id))
{
acks.Remove(id);
seenAcks.Add(id);
changed = true;
}
else
{
newPacketBlocks.Add(pb);
}
}
if (changed)
{
PacketAckPacket newPacket = new PacketAckPacket();
newPacket.Packets = new PacketAckPacket.PacketsBlock[newPacketBlocks.Count];
int a = 0;
foreach (PacketAckPacket.PacketsBlock pb in newPacketBlocks)
{
newPacket.Packets[a++] = pb;
}
SwapPacket(packet, (Packet)newPacket);
packet = newPacket;
needsCopy = false;
}
}
// check for appended ACKs
if (packet.Header.AppendedAcks)
{
int ackCount = packet.Header.AckList.Length;
for (int i = 0; i < ackCount; )
{
uint ackID = packet.Header.AckList[i]; // FIXME FIXME FIXME
if (acks.ContainsKey(ackID))
{
uint[] newAcks = new uint[ackCount - 1];
Array.Copy(packet.Header.AckList, 0, newAcks, 0, i);
Array.Copy(packet.Header.AckList, i + 1, newAcks, i, ackCount - i - 1);
packet.Header.AckList = newAcks;
--ackCount;
acks.Remove(ackID);
seenAcks.Add(ackID);
needsCopy = false;
}
else
++i;
}
if (ackCount == 0)
{
packet.Header.AppendedAcks = false;
packet.Header.AckList = new uint[0];
}
}
return packet;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:76,代码来源:GridProxy.cs
示例19: SendAcks
private void SendAcks()
{
lock (PendingAcks)
{
if (PendingAcks.Count > 0)
{
int i = 0;
PacketAckPacket acks = new PacketAckPacket();
acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count];
foreach (uint ack in PendingAcks)
{
acks.Packets[i] = new PacketAckPacket.PacketsBlock();
acks.Packets[i].ID = ack;
i++;
}
acks.Header.Reliable = false;
SendPacket(acks, true);
PendingAcks.Clear();
}
}
}
开发者ID:BackupTheBerlios,项目名称:libsecondlife-svn,代码行数:25,代码来源:NetworkManager.cs
示例20: SendAcks
/// <summary>
/// Sends out pending acknowledgements
/// </summary>
/// <returns>Number of ACKs sent</returns>
private int SendAcks()
{
uint ack;
int ackCount = 0;
if (PendingAcks.TryDequeue(out ack))
{
List<PacketAckPacket.PacketsBlock> blocks = new List<PacketAckPacket.PacketsBlock>();
PacketAckPacket.PacketsBlock block = new PacketAckPacket.PacketsBlock();
block.ID = ack;
blocks.Add(block);
while (PendingAcks.TryDequeue(out ack))
{
block = new PacketAckPacket.PacketsBlock();
block.ID = ack;
blocks.Add(block);
}
PacketAckPacket packet = new PacketAckPacket();
packet.Header.Reliable = false;
packet.Packets = blocks.ToArray();
ackCount = blocks.Count;
SendPacket(packet);
}
return ackCount;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:33,代码来源:Simulator.cs
注:本文中的PacketAckPacket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论