Initial Commit (broken due to version update)
This commit is contained in:
parent
74003df84b
commit
3f7b3b7440
3132 changed files with 1103305 additions and 0 deletions
39
Assets/Scripts/LiteNetLib/SimpleChannel.cs
Normal file
39
Assets/Scripts/LiteNetLib/SimpleChannel.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace LiteNetLib
|
||||
{
|
||||
internal sealed class SimpleChannel
|
||||
{
|
||||
private readonly Queue<NetPacket> _outgoingPackets;
|
||||
private readonly NetPeer _peer;
|
||||
|
||||
public SimpleChannel(NetPeer peer)
|
||||
{
|
||||
_outgoingPackets = new Queue<NetPacket>();
|
||||
_peer = peer;
|
||||
}
|
||||
|
||||
public void AddToQueue(NetPacket packet)
|
||||
{
|
||||
lock (_outgoingPackets)
|
||||
{
|
||||
_outgoingPackets.Enqueue(packet);
|
||||
}
|
||||
}
|
||||
|
||||
public bool SendNextPackets()
|
||||
{
|
||||
NetPacket packet;
|
||||
lock (_outgoingPackets)
|
||||
{
|
||||
while (_outgoingPackets.Count > 0)
|
||||
{
|
||||
packet = _outgoingPackets.Dequeue();
|
||||
_peer.SendRawData(packet);
|
||||
_peer.Recycle(packet);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue