/// <summary> /// Add this channel and new list<Inotifiable> to channelsubcribers if this channel doens't exist /// </summary> /// <param name="channel"></param> public void registerChannel(Channel channel) { if (!this.channelSubcribers.ContainsKey(channel)) { this.channelSubcribers.Add(channel, new List<INotifiable>()); } }
public GameCoreEventHandler() { this.broadcastChannel = new Channel(); this.notificationCenter = NotificationCenter.getInstance(); this.notificationCenter.registerChannel(this.broadcastChannel); //this.gameMachine = new GameStateMachine(); }
/// <summary> /// Add Inotifiable (client) to this channel if client doesn't exist client /// </summary> /// <param name="client"></param> /// <param name="channel"></param> public void subscribe(INotifiable client, Channel channel) { if (this.channelSubcribers.ContainsKey(channel) && !this.channelSubcribers[channel].Contains(client)) { this.channelSubcribers[channel].Add(client); } }
/// <summary> /// Broadcast all of clients in this channel /// </summary> /// <param name="channel"></param> /// <param name="notification"></param> public void broadcastNotification(Channel channel, Object notification) { if (this.channelSubcribers.ContainsKey(channel)) { foreach (INotifiable client in this.channelSubcribers[channel]) { client.receiveNotification(channel, notification); } } }
public void receiveNotification(Channel channel, object notification) { throw new NotImplementedException(); }