Esempio 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;
        }
Esempio 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);
        }
Esempio n. 3
0
        private void OnConnectionDisposed(WebSocketWrapper socket)
        {
            lock (pullingCallbackLock)
            {
                socket.OnDisposed -= OnConnectionDisposed;
                if (socket == pullingCallback)
                {
                    pullingCallback = null;
                }

                if (session.IsServiceSession)
                {
                    MarkJunk();
                }
            }
        }
Esempio 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;
            }
        }