public static Task WritePacketAsync(this BigEndianStream stream, Packet packet, int version) { if (packet == null) throw new ArgumentNullException("packet"); return packet.SendItemAsync(stream, version); }
/// <summary> /// Initializes a new instance of the <see cref="PacketEventArgs"/> class. /// </summary> /// <param name="packet">The packet.</param> /// <remarks></remarks> public PacketEventArgs(Packet packet) { Packet = packet; }
private static bool CheckPacket(Packet packet, int version, int requiredVersion, int lastSupportedVersion, bool throwOnRequired, bool throwOnLast) { if (packet == null) throw new ArgumentNullException("packet"); bool require = (requiredVersion == -1 || requiredVersion <= version); bool last = (lastSupportedVersion == -1 || lastSupportedVersion >= version); if (!require && throwOnRequired) throw new ArgumentException("packet does not support minecraft version", "packet", new PacketException(packet.Code)); if (!last && throwOnLast) throw new ArgumentException("packet does not support minecraft version", "packet", new PacketException(packet.Code)); bool supported = require && last; return supported; }
/// <summary> /// Writes the packet. /// </summary> /// <param name="stream"> The stream. </param> /// <param name="packet"> The packet. </param> /// <param name="version"> The version. </param> /// <remarks> /// </remarks> public static void WritePacket(this BigEndianStream stream, Packet packet, int version) { if (packet == null) throw new ArgumentNullException("packet"); packet.SendItem(stream, version); }
public static async Task SendPacketAsync(Packet packet, BigEndianStream stream, int version, int requiredVersion, int lastSupportedVersion, bool throwOnRequired, bool throwOnLast) { bool supported = CheckPacket(packet, version, requiredVersion, lastSupportedVersion, throwOnRequired, throwOnLast); if (!supported) return; await packet.SendItemAsync(stream, version); }
/// <summary> /// Creates a new instance of the <see cref="PacketReceivedEventArgs" /> class /// </summary> /// <param name="packet"> The packet which should be redirected </param> public PacketReceivedEventArgs(Packet packet) { Packet = packet; }
/// <summary> /// Creates a new instance of the <see cref="PacketReceivedEventArgs" /> class /// </summary> /// <param name="packet"> The packet which should be redirected </param> /// <param name="connection"> The connection this packet belongs to </param> public PacketReceivedEventArgs(Packet packet, IProxyConnection connection) { Packet = packet; Connection = connection; }
/// <summary> /// Send a packet to the client end point of the IProxyConnection /// </summary> /// <param name="connection"> The connection </param> /// <param name="packet"> The packet which should be sent </param> public static void SendClientPacket(this IProxyConnection connection, Packet packet) { connection.ClientEndPoint.SendPacket(packet); }
/// <summary> /// Send a packet to the server end point of the IProxyConnection /// </summary> /// <param name="connection"> The connection </param> /// <param name="packet"> The packet which should be sent </param> public static void SendServerPacket(this IProxyConnection connection, Packet packet) { connection.ServerEndPoint.SendPacket(packet); }