Example #1
0
        /// <summary>
        /// Creates a new instance of the network connection from the existing
        /// instance. The inner socket and direction will copied, but the caller
        /// can decide how the encryption and decryption will work.
        /// </summary>
        /// <param name="connection">The existing instance of the connection.</param>
        /// <param name="configurer">The new configuration.</param>
        public NetworkPoolConnection(NetworkPoolConnection connection, NetworkConfiguration configurer)
        {
            listener   = connection.listener;
            socket     = connection.socket;
            remote     = connection.remote;
            direction  = connection.direction;
            identifier = connection.identifier;

            incoming = new NetworkIncomingBuffer(connection.incoming, configurer.Decryptor);
            outgoing = new NetworkOutgoingBuffer(connection.outgoing, configurer.Encryptor);
        }
Example #2
0
        /// <summary>
        /// Creates a new instance of the network connection relying on the
        /// already connected socket instance and direction value indicating
        /// who is the initiator of the connection.
        /// </summary>
        /// <param name="listener"></param>
        /// <param name="socket">The already connected socket.</param>
        /// <param name="direction">The direction indicating who initiated the connection.</param>
        /// <param name="identifier"></param>
        public NetworkPoolConnection(NetworkPoolListener listener, TcpSocket socket, NetworkDirection direction, long identifier, IPEndPoint remote)
        {
            this.listener   = listener;
            this.socket     = socket;
            this.direction  = direction;
            this.identifier = identifier;

            this.remote = NetworkAddress.Parse(remote);

            incoming = new NetworkIncomingBuffer(listener, socket, identifier);
            outgoing = new NetworkOutgoingBuffer(listener, socket, identifier);
        }
Example #3
0
        /// <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);
        }
Example #4
0
 public NetworkPoolSend(long identifier, NetworkOutgoingBuffer buffer, NetworkOutgoingMessage message)
 {
     this.identifier = identifier;
     this.buffer     = buffer;
     this.message    = message;
 }