Ejemplo n.º 1
0
        /// <summary>
        ///  Constructor. Initialize member variables.
        /// </summary>
        /// <param name="transportConfig">Provides the transport parameters.</param>
        /// <param name="decodePacketCallback">Callback of decoding packet.</param>
        /// <param name="certificate">X509 certificate.</param>
        public RdpbcgrServerTransportStack(
            RdpbcgrServer rdpbcgrServer,
            RdpcbgrServerTransportConfig transportConfig,
            DecodePacketCallback decodePacketCallback,
            X509Certificate2 certificate)
        {
            this.rdpbcgrServer = rdpbcgrServer;
            this.config        = transportConfig;
            if (this.config == null)
            {
                throw new System.InvalidCastException("TcpServerTransport needs SocketTransportConfig.");
            }

            this.decoder     = decodePacketCallback;
            this.packetQueue = new QueueManager();
            this.listenSock  = new Socket(transportConfig.LocalIpAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            this.listenSock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
            this.streamType = transportConfig.StreamType;
            IPEndPoint endPoint = new IPEndPoint(config.LocalIpAddress, config.LocalIpPort);

            this.listenSock.Bind(endPoint);
            this.listenSock.Listen(config.MaxConnections);
            this.acceptThread     = new Thread(new ThreadStart(AcceptLoop));
            this.receivingStreams = new Dictionary <Socket, RdpbcgrReceiveThread>();
            this.cert             = certificate;
        }
Ejemplo n.º 2
0
        /// <summary>
        ///  Constructor. Initialize member variables.
        /// </summary>
        /// <param name="transportConfig">Provides the transport parameters.</param>
        /// <param name="decodePacketCallback">Callback of decoding packet.</param>
        public RdpbcgrServerTransportStack(
            RdpbcgrServer rdpbcgrServer,
            RdpcbgrServerTransportConfig transportConfig,
            DecodePacketCallback decodePacketCallback)
        {
            this.rdpbcgrServer = rdpbcgrServer;
            this.config        = transportConfig;
            if (this.config == null)
            {
                throw new System.InvalidCastException("TcpServerTransport needs SocketTransportConfig.");
            }

            this.decoder     = decodePacketCallback;
            this.packetQueue = new QueueManager();

            this.receivingStreams = new Dictionary <Socket, RdpbcgrReceiveThread>();
        }
        /// <summary>
        ///  Constructor. Initialize member variables.
        /// </summary>
        /// <param name="transportConfig">Provides the transport parameters.</param>
        /// <param name="decodePacketCallback">Callback of decoding packet.</param>
        /// <param name="certificate">X509 certificate.</param>
        public RdpbcgrServerTransportStack(
            RdpbcgrServer rdpbcgrServer,
            RdpcbgrServerTransportConfig transportConfig,
            DecodePacketCallback decodePacketCallback,
            X509Certificate2 certificate)
        {
            this.rdpbcgrServer = rdpbcgrServer;
            this.config = transportConfig;
            if (this.config == null)
            {
                throw new System.InvalidCastException("TcpServerTransport needs SocketTransportConfig.");
            }

            this.decoder = decodePacketCallback;
            this.packetQueue = new QueueManager();
            this.listenSock = new Socket(transportConfig.LocalIpAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            this.streamType = transportConfig.StreamType;
            IPEndPoint endPoint = new IPEndPoint(config.LocalIpAddress, config.LocalIpPort);
            this.listenSock.Bind(endPoint);
            this.listenSock.Listen(config.MaxConnections);
            this.acceptThread = new Thread(new ThreadStart(AcceptLoop));
            this.receivingStreams = new Dictionary<Socket, RdpbcgrReceiveThread>();
            this.cert = certificate;
        }