Exemplo n.º 1
0
        public void Dispose()
        {
            if (isDisposed)
            {
                return;
            }

            isDisposed = true;

            OnDisposed?.Invoke(this, new EventArgs());

            if (userActivityTimeout > 0 && EnvironmentHelper.CurrentTime.Subtract(lastUserActionDate) > TimeSpan.FromSeconds(userActivityTimeout))
            {
                Logger.Log("Disposing session stream {0}/{1} due to user timeout", session.SessionId, streamId);
            }
            else
            {
                Logger.Log("Disposing session stream {0}/{1} due to unexpected reason", session.SessionId, streamId);
            }

            lock (pullingCallbackLock)
            {
                if (pullingCallback != null)
                {
                    pullingCallback.OnDisposed -= OnConnectionDisposed;
                    pullingCallback.Dispose();
                    pullingCallback = null;
                }
            }

            userInfo?.Dispose();
            userInfo = null;
        }
Exemplo n.º 2
0
        public void SetPullingCallback(string gameId, string gameToken, WebSocketWrapper wrapper)
        {
            var streamWrapper = GetStreamWrapper(gameId, false);

            if (streamWrapper == null || streamWrapper.GameInstanceId != gameToken)
            {
                throw new SessionExpiredException();
            }

            streamWrapper.SetPullingCallback(wrapper);
        }
Exemplo n.º 3
0
        private void OnConnectionDisposed(WebSocketWrapper socket)
        {
            lock (pullingCallbackLock)
            {
                socket.OnDisposed -= OnConnectionDisposed;
                if (socket == pullingCallback)
                {
                    pullingCallback = null;
                }

                if (session.IsServiceSession)
                {
                    MarkJunk();
                }
            }
        }
Exemplo n.º 4
0
        public void SetPullingCallback(WebSocketWrapper wrapper)
        {
            lock (pullingCallbackLock)
            {
                if (pullingCallback != null)
                {
                    pullingCallback.OnDisposed -= OnConnectionDisposed;
                    pullingCallback.Dispose();
                }

                pullingCallback = wrapper;
                if (pullingCallback != null)
                {
                    pullingCallback.OnDisposed += OnConnectionDisposed;
                }

                sendOffset = 0;
            }
        }