예제 #1
0
        public Game CreateGameWithScenario( User creator, string scenario, string name )
        {
            var game = new Game( name, creator.Id );
            game.Scenario = scenario;

            this.AddPlayer( game, creator.Id );

            return game;
        }
예제 #2
0
파일: UserHandler.cs 프로젝트: upta/gemfire
        public void ReassignUser( string connectionId, User user )
        {
            if ( user.ConnectionId != null )
            {
                User garbage;
                this.users.TryRemove( user.ConnectionId, out garbage );
            }

            user.ConnectionId = connectionId;
            this.users.TryAdd( connectionId, user );
        }
예제 #3
0
파일: Lobby.cs 프로젝트: upta/gemfire
        public InitDto InitializeClient( string registrationId )
        {
            if ( this.registrationHandler.RegistrationExists( registrationId ) )
            {
                var rc = this.registrationHandler.RemoveRegistration( registrationId );

                if ( this.userHandler.UserExists( this.Context.ConnectionId ) )
                {
                    return null;
                }

                var user = this.userHandler.FindUserByIdentity( rc.Identity );

                if ( user == null )
                {
                    user = new User( this.Context.ConnectionId, rc );
                }
                else
                {
                    user.RegistrationTicket = rc;
                    this.userHandler.ReassignUser( this.Context.ConnectionId, user );
                }

                this.userHandler.AddUser( user ); // will ensure that they're persisted

                // add the user into the groups for any games to which he belongs
                var usersGames = this.gameHandler.GetGames().Where( a => a.Players.Any( b => b == user.Id ) );

                foreach ( var game in usersGames )
                {
                    this.Groups.Add( user.ConnectionId, game.GroupName );
                }

                return new InitDto
                {
                    Scenarios = this.scenarioHandler.GetScenarioNames(),
                    UserId = user.Id
                };
            }

            return null;
        }
예제 #4
0
파일: UserHandler.cs 프로젝트: upta/gemfire
        public void AddUser( User user )
        {
            this.repository.Save<User>( user );

            this.users.TryAdd( user.ConnectionId, user );
        }