Пример #1
0
 public SessionSpectator(int id, Session session, CreateSpectatorData data)
 {
     this.id = id;
     this.session = session;
     this.data = data;
     control = new SessionSpectatorControl(this);
 }
Пример #2
0
        public void Spectate(Password password, CreateSpectatorData data, ISpectatorSessionEventListener listener)
        {
            if(state == SessionState.Ended)
                throw new BadSessionStateException();
            lock(Lock)
            {
                if(!this.data.SpectatorPassword.CheckPassword(password))
                    throw new BadSessionPasswordException();
                if(spectators.Count >= this.data.MaxSpectators)
                    throw new TooManySpectatorsException();

                int id = spectators.GenerateID();
                SessionSpectator spectator = new SessionSpectator(id, this, data);
                spectators.Add(id, spectator);
                spectatorList.Add(spectator);
                spectator.RegisterListener(listener);
                eventMgr.SendController(spectator);
                if(state == SessionState.Playing)
                    game.RegisterSpectator(spectator);
                eventMgr.OnSpectatorJoinedSession(spectator);
                server.SaveState();
            }
        }