Exemple #1
0
        public async Task Login(IScenePeerClient peer, User user, PlatformId onlineId)
        {
            if (peer == null)
            {
                throw new ArgumentNullException("peer");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            bool added = false;

            while (!added)
            {
                var r = await _userPeerIndex.GetOrAdd(user.Id, peer.Id);

                if (r.Value != peer.Id)
                {
                    await LogOut(r.Value);
                }
                else
                {
                    added = true;
                }
            }


            await _userPeerIndex.TryAdd(onlineId.ToString(), peer.Id);

            await _peerUserIndex.TryAdd(peer.Id.ToString(), new Session { User = user, platformId = onlineId });

            await _eventHandlers.RunEventHandler(h => h.OnLoggedIn(peer, user, onlineId), ex => logger.Log(LogLevel.Error, "usersessions", "An error occured while running LoggedIn event handlers", ex));

            await _userService.LoginEventOccured(user, peer);

            //logger.Trace("usersessions", $"Added '{user.Id}' (peer : '{peer.Id}') in scene '{_scene.Id}'.");
        }
Exemple #2
0
 public Task <Session> GetSession(PlatformId id)
 {
     return(GetSession(id.ToString()));
 }