Пример #1
0
        private void OnConnect(object sender, UserConnectEvent uce)
        {
            if (sender == this)
            {
                return;
            }

            lock (Sync) {
                if (Users.Any(u => u.UserId == uce.UserId))
                {
                    throw new ArgumentException(@"User already registered?????", nameof(uce));
                }

                Users.Add(new User(
                              uce.UserId,
                              uce.Name,
                              uce.Colour,
                              uce.Rank,
                              uce.Permissions,
                              uce.Status,
                              uce.StatusMessage,
                              uce.NickName
                              ));
            }
        }
Пример #2
0
        protected virtual void OnPendingPlayerConnecting(ValidateAuthTicketResponse_t callback, ref bool isValid, ref string explanation)
        {
            if (m_PendingUsers.Any(d => d.SteamId == callback.m_SteamID))
            {
                return;
            }

            if (!isValid)
            {
                return;
            }

            //todo check if it is working, if not this should be patched
            var isPendingValid    = isValid;
            var rejectExplanation = explanation;

            AsyncHelper.RunSync(async() =>
            {
                var steamPending = Provider.pending.FirstOrDefault(d => d.playerID.steamID == callback.m_SteamID);
                if (steamPending == null)
                {
                    return;
                }

                var pendingUser = new UnturnedPendingUser(this, m_UserDataStore, steamPending);
                var userData    = await m_UserDataStore.GetUserDataAsync(pendingUser.Id, pendingUser.Type);
                if (userData != null)
                {
                    userData.LastSeen        = DateTime.Now;
                    userData.LastDisplayName = pendingUser.DisplayName;
                    await m_UserDataStore.SetUserDataAsync(userData);
                }
                else
                {
                    await m_DataSeeder.SeedUserDataAsync(pendingUser.Id, pendingUser.Type, pendingUser.DisplayName);
                    await m_EventBus.EmitAsync(m_Runtime, this, new UserFirstConnectEvent(pendingUser));
                }

                m_PendingUsers.Add(pendingUser);

                var userConnectingEvent = new UserConnectEvent(pendingUser);
                await m_EventBus.EmitAsync(m_Runtime, this, userConnectingEvent);

                if (!string.IsNullOrEmpty(userConnectingEvent.RejectionReason))
                {
                    isPendingValid    = false;
                    rejectExplanation = userConnectingEvent.RejectionReason;
                }

                if (userConnectingEvent.IsCancelled)
                {
                    isPendingValid = false;
                }
            });

            isValid     = isPendingValid;
            explanation = rejectExplanation;
        }
Пример #3
0
 public UserConnectPacket(UserConnectEvent connect)
 {
     Connect = connect ?? throw new ArgumentNullException(nameof(connect));
 }