コード例 #1
0
        public RemoteSessionEventSourceHandler(HttpContext context, string clientId)
        {
            _context = context;

            try
            {
                if (context.Session[HttpSessionStateVariables.RemoteSession.ToString()] == null)
                {
                    throw new NullReferenceException();
                }

                // retrieve the remote session for the given http session
                _remoteSession = (RemoteSession)context.Session[HttpSessionStateVariables.RemoteSession.ToString()];

                if (!_remoteSession.Manager.Clients.ContainsKey(clientId))
                {
                    lock (_remoteSession.Manager.ClientsLock)
                    {
                        _remoteSession.Manager.Clients.Add(clientId, new RemoteSessionClient(clientId));
                    }
                }

                _client = _remoteSession.Manager.Clients[clientId];
            }
            catch (Exception exc)
            {
                Trace.TraceError("Failed to initialize event source handler ({0})", exc);
            }
        }
コード例 #2
0
        public RemoteSessionSocketHandler(HttpContext context, bool binary, string clientId, WebSocketDirection direction)
            : base()
        {
            _session  = context.Session;
            Binary    = binary;
            Direction = direction;

            try
            {
                if (context.Session[HttpSessionStateVariables.RemoteSession.ToString()] == null)
                {
                    throw new NullReferenceException();
                }

                // retrieve the remote session for the given http session
                _remoteSession = (RemoteSession)context.Session[HttpSessionStateVariables.RemoteSession.ToString()];

                if (!_remoteSession.Manager.Clients.ContainsKey(clientId))
                {
                    lock (_remoteSession.Manager.ClientsLock)
                    {
                        _remoteSession.Manager.Clients.Add(clientId, new RemoteSessionClient(clientId));
                    }
                }

                _client = _remoteSession.Manager.Clients[clientId];
            }
            catch (Exception exc)
            {
                Trace.TraceError("Failed to initialize socket handler ({0})", exc);
            }
        }
コード例 #3
0
        public RemoteSessionAudioSocketHandler(HttpContext context, bool binary)
            : base()
        {
            _context = context;
            Binary   = binary;

            try
            {
                if (context.Session[HttpSessionStateVariables.RemoteSession.ToString()] == null)
                {
                    throw new NullReferenceException();
                }

                // retrieve the remote session for the given http session
                _remoteSession = (RemoteSession)context.Session[HttpSessionStateVariables.RemoteSession.ToString()];
            }
            catch (Exception exc)
            {
                Trace.TraceError("Failed to retrieve the remote session for the http session {0}, ({1})", context.Session.SessionID, exc);
                return;
            }

            var clientId = context.Session.SessionID;

            if (context.Request.Cookies[HttpRequestCookies.ClientKey.ToString()] != null)
            {
                clientId = context.Request.Cookies[HttpRequestCookies.ClientKey.ToString()].Value;
            }

            if (!_remoteSession.Manager.Clients.ContainsKey(clientId))
            {
                lock (_remoteSession.Manager.ClientsLock)
                {
                    _remoteSession.Manager.Clients.Add(clientId, new RemoteSessionClient(clientId));
                }
            }

            _client = _remoteSession.Manager.Clients[clientId];

            bool audioBuffering;

            if (!bool.TryParse(ConfigurationManager.AppSettings["AudioBuffering"], out audioBuffering))
            {
                audioBuffering = true;
            }

            // RDP: audio blocks are buffered for a seamless playback; buffer data is also invalidated past the audio cache duration (default 1,5 sec) in case of lag
            // SSH: no audio
            if (audioBuffering && _remoteSession.HostType == HostType.RDP)
            {
                Buffer = new DataBuffer <int>(_bufferCount, _bufferDelay);
                Buffer.SendBufferData = SendBufferData;
            }
        }
コード例 #4
0
        public RemoteSessionSocketHandler(HttpContext context, bool binary, WebSocketDirection direction)
            : base()
        {
            _session  = context.Session;
            Binary    = binary;
            Direction = direction;

            try
            {
                if (context.Session[HttpSessionStateVariables.RemoteSession.ToString()] == null)
                {
                    throw new NullReferenceException();
                }

                // retrieve the remote session for the given http session
                _remoteSession = (RemoteSession)context.Session[HttpSessionStateVariables.RemoteSession.ToString()];
            }
            catch (Exception exc)
            {
                Trace.TraceError("Failed to retrieve the remote session for the http session {0}, ({1})", context.Session.SessionID, exc);
                return;
            }

            var clientId = context.Session.SessionID;

            if (context.Request.Cookies[HttpRequestCookies.ClientKey.ToString()] != null)
            {
                clientId = context.Request.Cookies[HttpRequestCookies.ClientKey.ToString()].Value;
            }

            if (!_remoteSession.Manager.Clients.ContainsKey(clientId))
            {
                lock (_remoteSession.Manager.ClientsLock)
                {
                    _remoteSession.Manager.Clients.Add(clientId, new RemoteSessionClient(clientId));
                }
            }

            _client = _remoteSession.Manager.Clients[clientId];
        }