Ejemplo n.º 1
0
        /// <summary>
        /// Start multitransport connect with server.
        /// </summary>
        /// <param name="serverInitiateMultitransportRequestPDUs">The Server Intiate Multitransport Request PDUs sent by server.</param>

        public void StartMultitransportConnect(Server_Initiate_Multitransport_Request_PDU[] requests)
        {
            foreach (var request in requests)
            {
                TransportMode mode;

                switch (request.requestedProtocol)
                {
                case Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECR:
                    mode = TransportMode.Reliable;
                    break;

                case Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECL:
                    mode = TransportMode.Lossy;
                    break;

                default:
                    throw new InvalidOperationException("Unexpected requestedProtocol!");
                }

                serverInitiateMultitransportRequestPDUs[request.requestedProtocol] = request;

                var rdpeudpClient = new RdpeudpClient(new IPEndPoint(testConfig.localAddress.ParseIPAddress(), 0), new IPEndPoint(testConfig.serverName.ParseIPAddress(), testConfig.serverPort), mode, true);

                rdpeudpClient.UnhandledExceptionReceived += (ex) =>
                {
                    Site.Log.Add(LogEntryKind.Debug, $"Unhandled exception from RdpeudpClient: {ex}");
                };

                rdpeudpClients[request.requestedProtocol] = rdpeudpClient;

                rdpeudpClient.Start();

                rdpeudpClient.Connect(testConfig.multiTransportTimeout);


                var rdpemtClient = new RdpemtClient(rdpeudpClient.Socket, testConfig.serverName, false, testConfig.tlsVersion);

                rdpemtClient.PDUReceived += VerifyPDU;

                rdpemtClients[request.requestedProtocol] = rdpemtClient;
            }
        }
        /// <summary>
        /// Establish a MultiTransport Connection
        /// </summary>
        public void EstablishTransportConnection()
        {
            TransportMode udpTransportMode = TransportMode.Reliable;
            uint          requestId        = clientSessionContext.RequestIdReliable;

            byte[] cookie = clientSessionContext.CookieReliable;
            int    port   = portR;

            if (transportProtocol == Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECL)
            {
                udpTransportMode = TransportMode.Lossy;
                requestId        = clientSessionContext.RequestIdLossy;
                cookie           = clientSessionContext.CookieLossy;
                port             = portL;
            }

            if (cookie == null)
            {
                // Not receive a Server Initiate Multitransport Request PDU
                throw new InvalidOperationException("Cannot establish the connection, since the corresponding Server Initiate Multitransport Request PDU wasn't received!");
            }

            IPEndPoint localEndpoint = new IPEndPoint(((IPEndPoint)clientSessionContext.LocalIdentity).Address, port);

            rdpeudpClient = new RdpeudpClient(localEndpoint, (IPEndPoint)clientSessionContext.RemoteIdentity, udpTransportMode);

            rdpeudpClient.UnhandledExceptionReceived += (ex) =>
            {
                UnhandledExceptionReceived?.Invoke(ex);
            };

            rdpeudpClient.Start();

            rdpeudpClient.Connect(timeout);

            rdpemtClient           = new RdpemtClient(rdpeudpClient.Socket, ((IPEndPoint)clientSessionContext.RemoteIdentity).Address.ToString(), false);
            rdpemtClient.Received += ReceivedBytes;

            rdpemtClient.Connect(requestId, cookie, timeout);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Start multitransport connect with server.
        /// </summary>
        /// <param name="serverInitiateMultitransportRequestPDUs">The Server Intiate Multitransport Request PDUs sent by server.</param>

        public void StartMultitransportConnect(Server_Initiate_Multitransport_Request_PDU[] requests)
        {
            foreach (var request in requests)
            {
                TransportMode mode;

                switch (request.requestedProtocol)
                {
                case Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECR:
                    mode = TransportMode.Reliable;
                    break;

                case Multitransport_Protocol_value.INITITATE_REQUEST_PROTOCOL_UDPFECL:
                    mode = TransportMode.Lossy;
                    break;

                default:
                    throw new InvalidOperationException("Unexpected requestedProtocol!");
                }

                serverInitiateMultitransportRequestPDUs[request.requestedProtocol] = request;

                var rdpeudpClient = new RdpeudpClient(new IPEndPoint(localAddress.ParseIPAddress(), 0), new IPEndPoint(serverName.ParseIPAddress(), serverPort), mode, true);

                rdpeudpClients[request.requestedProtocol] = rdpeudpClient;

                rdpeudpClient.Start();

                rdpeudpClient.Connect(timeout);


                var rdpemtClient = new RdpemtClient(rdpeudpClient.Socket, serverName, false);

                rdpemtClient.PDUReceived += VerifyPDU;

                rdpemtClients[request.requestedProtocol] = rdpemtClient;
            }
        }