/// <summary> /// Creates a new instance of the network incoming buffer relying on the already /// connected socket instance. The buffer does not decrypt anything. /// </summary> /// <param name="listener">The listener who knows the pool.</param> /// <param name="socket">The already connected socket.</param> /// <param name="identifier">The unique connection identifier.</param> public NetworkIncomingBuffer(NetworkPoolListener listener, TcpSocket socket, long identifier) { this.listener = listener; this.socket = socket; this.identifier = identifier; memory = listener.Allocate(); }
/// <summary> /// Creates a new instance of the network outgoing buffer relying on the already /// connected socket instance. The buffer does not encrypt anything. /// </summary> /// <param name="listener">The listener who knows the pool.</param> /// <param name="socket">The already connected socket.</param> /// <param name="identifier">The unique connection identifier.</param> public NetworkOutgoingBuffer(NetworkPoolListener listener, TcpSocket socket, long identifier) { this.listener = listener; this.socket = socket; this.identifier = identifier; memory = listener.Allocate(); parts = new HashSet <int>(); }
/// <summary> /// Creates a new instance of the network outgoing buffer from the existing instance. /// The inner socket and the already downloaded and waiting data will be /// copied, but the caller can change the encryption algorithm. /// </summary> /// <param name="buffer">The existing instance of the newtwork buffer.</param> /// <param name="encryptor">The new encryptor.</param> public NetworkOutgoingBuffer(NetworkOutgoingBuffer buffer, NetworkOutgoingEncryptor encryptor) { this.encryptor = encryptor; listener = buffer.listener; socket = buffer.socket; identifier = buffer.identifier; memory = buffer.memory; offset = buffer.offset; parts = buffer.parts; encryptor?.Encrypt(memory.Data, 0, offset); }
/// <summary> /// Creates a new instance of the network incoming buffer from the existing instance. /// The inner socket and the already downloaded and waiting data will be /// copied, but the caller can change the decryption algorithm. /// </summary> /// <param name="buffer">The existing instance of the newtwork buffer.</param> /// <param name="decryptor">The new decryptor.</param> public NetworkIncomingBuffer(NetworkIncomingBuffer buffer, NetworkIncomingDecryptor decryptor) { this.decryptor = decryptor; listener = buffer.listener; socket = buffer.socket; identifier = buffer.identifier; memory = buffer.memory; length = buffer.length; offset = buffer.offset; Decrypt(offset, length); }