本文整理汇总了C#中Package.PutPool方法的典型用法代码示例。如果您正苦于以下问题:C# Package.PutPool方法的具体用法?C# Package.PutPool怎么用?C# Package.PutPool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package.PutPool方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendPackage
/// <summary>
/// Very important litle method. This does all the sending of packages for
/// the player class. Treat with respect!
/// </summary>
public void SendPackage(Package package, bool sendDirect = false)
{
if (package == null) return;
if (!IsConnected)
{
package.PutPool();
return;
}
bool isBatch = package is McpeBatch;
if (!isBatch)
{
var result = Server.PluginManager.PluginPacketHandler(package, false, this);
if (result != package) package.PutPool();
package = result;
}
if (package == null) return;
lock (_queueSync)
{
_sendQueueNotConcurrent.Enqueue(package);
}
}
示例2: SendPackage
public void SendPackage(Player player, Package message, int mtuSize, Reliability reliability = Reliability.Reliable)
{
if (message == null) return;
PlayerNetworkSession session;
if (_playerSessions.TryGetValue(player.EndPoint, out session))
{
foreach (var datagram in Datagram.CreateDatagrams(message, mtuSize, session))
{
SendDatagram(session, datagram);
}
TraceSend(message);
message.PutPool();
//Thread.Sleep(1); // Really important to slow down speed a bit
}
}
示例3: SendPackage
public void SendPackage(Player player, Package message, int mtuSize, ref int reliableMessageNumber, Reliability reliability = Reliability.Reliable)
{
if (message == null) return;
PlayerNetworkSession session;
if (_playerSessions.TryGetValue(player.EndPoint, out session))
{
Datagram.CreateDatagrams(message, mtuSize, ref reliableMessageNumber, session, SendDatagram);
message.PutPool();
}
Thread.Sleep(1); // Really important to slow down speed a bit
}
示例4: SendPackage
private void SendPackage(Package package)
{
SendPackage(package, _mtuSize, ref _reliableMessageNumber);
package.PutPool();
}
示例5: SendPackage
private void SendPackage(Package package)
{
SendPackage(_serverTargetEndpoint, new List<Package>() {package}, _mtuSize, ref _datagramSequenceNumber, ref _reliableMessageNumber);
package.PutPool();
}
示例6: SendPackage
private void SendPackage(Package package)
{
SendPackage(new List<Package> {package}, _mtuSize, ref _reliableMessageNumber);
package.PutPool();
}
示例7: SendPackage
/// <summary>
/// Very important litle method. This does all the sending of packages for
/// the player class. Treat with respect!
/// </summary>
public void SendPackage(Package package, bool sendDirect = false)
{
if (package == null) return;
if (!IsConnected)
{
package.PutPool();
return;
}
bool isBatch = package is McpeBatch;
if (!isBatch)
{
var result = Server.PluginManager.PluginPacketHandler(package, false, this);
if (result != package) package.PutPool();
package = result;
}
if (package == null) return;
if (!IsSpawned || sendDirect || isBatch)
{
Server.SendPackage(this, new List<Package>(new[] {package}), _mtuSize, ref _reliableMessageNumber);
}
else
{
lock (_queueSync)
{
_sendQueueNotConcurrent.Enqueue(package);
}
}
}
示例8: SendPackage
public int SendPackage(Package message, short mtuSize, int sequenceNumber, int reliableMessageNumber, Reliability reliability = Reliability.Reliable)
{
byte[] encodedMessage = message.Encode();
//int count = (int) Math.Ceiling(encodedMessage.Length/((double) mtuSize - 60));
int count = 1;
int index = 0;
short splitId = (short) (sequenceNumber%65536);
//foreach (var bytes in ArraySplit(encodedMessage, mtuSize - 60))
//{
ConnectedPackage package = new ConnectedPackage
{
Buffer = encodedMessage,
_reliability = reliability,
_reliableMessageNumber = reliableMessageNumber++,
_datagramSequenceNumber = sequenceNumber++,
_hasSplit = count > 1,
_splitPacketCount = count,
_splitPacketId = splitId,
_splitPacketIndex = index++
};
byte[] data = package.Encode();
SendData(data);
//}
message.PutPool();
return count;
}
示例9: HandlePackage
internal void HandlePackage(int datagramSequenceNumber, Package message, PlayerNetworkSession playerSession)
{
TraceReceive(message);
message.DatagramSequenceNumber = datagramSequenceNumber;
if (typeof (UnknownPackage) == message.GetType())
{
message.PutPool();
return;
}
if (typeof (McpeBatch) == message.GetType())
{
McpeBatch batch = (McpeBatch) message;
var messages = new List<Package>();
// Get bytes
byte[] payload = batch.payload;
// Decompress bytes
MemoryStream stream = new MemoryStream(payload);
if (stream.ReadByte() != 0x78)
{
throw new InvalidDataException("Incorrect ZLib header. Expected 0x78 0x9C");
}
stream.ReadByte();
using (var defStream2 = new DeflateStream(stream, CompressionMode.Decompress, false))
{
// Get actual package out of bytes
MemoryStream destination = new MemoryStream();
defStream2.CopyTo(destination);
byte[] internalBuffer = destination.ToArray();
messages.Add(PackageFactory.CreatePackage(internalBuffer[0], internalBuffer) ?? new UnknownPackage(internalBuffer[0], internalBuffer));
}
foreach (var msg in messages)
{
HandlePackage(datagramSequenceNumber, msg, playerSession);
}
batch.PutPool();
return;
}
message.Source = "HandlePackage";
playerSession.Player.HandlePackage(message);
message.PutPool();
}
示例10: SendPackage
/// <summary>
/// Very important litle method. This does all the sending of packages for
/// the player class. Treat with respect!
/// </summary>
public void SendPackage(Package package, bool sendDirect = false)
{
if (!IsConnected) return;
var result = _pluginManager.PluginPacketHandler(package, false, this);
if (result != package) package.PutPool();
package = result;
if (package == null) return;
if (IsSpawned && !sendDirect)
{
lock (_queueSync)
{
_sendQueueNotConcurrent.Enqueue(package);
}
}
else
{
Server.SendPackage(this, EndPoint, new List<Package>(new[] {package}), _mtuSize, ref _reliableMessageNumber);
}
}
示例11: HandlePackage
/// <summary>
/// Handles the package.
/// </summary>
/// <param name="message">The message.</param>
public void HandlePackage(Package message)
{
var result = _pluginManager.PluginPacketHandler(message, true, this);
if (result != message) message.PutPool();
message = result;
if (message == null) return;
if (typeof (McpeContainerSetSlot) == message.GetType())
{
HandleContainerSetSlot((McpeContainerSetSlot) message);
}
else if (typeof (McpeContainerClose) == message.GetType())
{
HandleMcpeContainerClose((McpeContainerClose) message);
}
else if (typeof (McpePlayerEquipment) == message.GetType())
{
HandlePlayerEquipment((McpePlayerEquipment) message);
}
else if (typeof (McpePlayerArmorEquipment) == message.GetType())
{
HandlePlayerArmorEquipment((McpePlayerArmorEquipment) message);
}
else if (typeof (McpeUpdateBlock) == message.GetType())
{
// DO NOT USE. Will dissapear from MCPE any release.
// It is a bug that it leaks these messages.
}
else if (typeof (McpeRemoveBlock) == message.GetType())
{
HandleRemoveBlock((McpeRemoveBlock) message);
}
else if (typeof (McpeAnimate) == message.GetType())
{
HandleAnimate((McpeAnimate) message);
}
else if (typeof (McpeUseItem) == message.GetType())
{
HandleUseItem((McpeUseItem) message);
}
else if (typeof (ConnectedPing) == message.GetType())
{
HandleConnectedPing((ConnectedPing) message);
}
else if (typeof (ConnectedPong) == message.GetType())
{
HandleConnectedPong((ConnectedPong) message);
}
else if (typeof (ConnectionRequest) == message.GetType())
{
HandleConnectionRequest((ConnectionRequest) message);
}
else if (typeof (NewIncomingConnection) == message.GetType())
{
HandleNewIncomingConnection((NewIncomingConnection) message);
}
else if (typeof (DisconnectionNotification) == message.GetType())
{
HandleDisconnectionNotification();
}
else if (typeof (McpeText) == message.GetType())
{
HandleMessage((McpeText) message);
}
else if (typeof (McpeRemovePlayer) == message.GetType())
{
// Do nothing right now, but should clear out the entities and stuff
// from this players internal structure.
}
else if (typeof (McpeLogin) == message.GetType())
{
HandleLogin((McpeLogin) message);
}
else if (typeof (McpeMovePlayer) == message.GetType())
{
HandleMovePlayer((McpeMovePlayer) message);
}
else if (typeof (McpeInteract) == message.GetType())
//.........这里部分代码省略.........