Exemplo n.º 1
0
 public void OnSpectatorLeftSession(Session session, SessionSpectator spectator)
 {
     List<IServerEventListener> listeners = new List<IServerEventListener>(this.listeners);
     foreach(IServerEventListener l in listeners)
         sender.SendEvent(li => {
             li.OnSpectatorLeftSession(session, spectator);
         }, l);
 }
Exemplo n.º 2
0
 public void RemoveSpectator(SessionSpectator spectator)
 {
     lock(Lock)
     {
         spectator.UnregisterListener();
         spectator.Control.Disconnect();
         spectators.Remove(spectator.ID);
         spectatorList.Remove(spectator);
         eventMgr.OnSpectatorLeftSession(spectator);
         spectator.Disconnect();
         server.SaveState();
     }
 }
Exemplo n.º 3
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();
            }
        }
 public SessionSpectatorControl(SessionSpectator spectator)
 {
     this.spectator = spectator;
 }