Esempio n. 1
0
        protected virtual void OnPlayerDisconnected(SteamPlayer steamPlayer)
        {
            var user = GetUser(steamPlayer.playerID.steamID);

            if (user == null)
            {
                return;
            }

            if (user.Session is UnturnedUserSession session)
            {
                session.OnSessionEnd();
            }

            AsyncHelper.RunSync(async() =>
            {
                var disconnectedEvent = new UnturnedUserDisconnectedEvent(user);
                await m_EventBus.EmitAsync(m_Runtime, this, disconnectedEvent);

                m_Users.Remove(user);

                var userData = await m_UserDataStore.GetUserDataAsync(user.Id, user.Type);
                if (userData == null)
                {
                    return;
                }

                userData.LastSeen = DateTime.Now;
                await m_UserDataStore.SetUserDataAsync(userData);
            });
        }
Esempio n. 2
0
        protected virtual void OnPlayerDisconnected(CSteamID steamID)
        {
            var user = GetUser(steamID);

            if (user == null)
            {
                return;
            }

            if (user.Session is UnturnedUserSession session)
            {
                session.OnSessionEnd();
            }

            AsyncHelper.RunSync(async() =>
            {
                var disconnectedEvent = new UnturnedUserDisconnectedEvent(user);
                await m_EventBus.EmitAsync(m_Runtime, this, disconnectedEvent);
            });

            m_Users.Remove(user);
            UpdateLastSeen(user.Id, user.Type);
        }