// Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java
// public class Participant implements Comparable<Participant> {
// 
//   private ObjectId id;
// 
//   private String name;
// 
//   public Participant(String name) {
//     this.name = name;
// 
//     this.id = new ObjectId();
//   }
// 
//   public Participant() {
//   }
// 
//   public String getId() {
//     return id.toString();
//   }
// 
//   public String getName() {
//     return name;
//   }
// 
//   public void setName(String name) {
//     this.name = name;
//   }
// 
//   public int compareTo(Participant o) {
//     return o.id.compareTo(id);
//   }
// }
// 
// Path: server/src/main/java/de/nixis/web/disco/room/Room.java
// public interface Room {
// 
//   public String id();
// 
//   public Map<Channel, String> channelMap();
// 
//   public Set<Channel> channels();
// 
//   public <T> Attribute<T> attr(AttributeKey<T> key);
// 
//   Map<String, Participant> participantsMap();
// }
// 
// Path: server/src/main/java/de/nixis/web/disco/room/RoomContext.java
// public interface RoomContext {
// 
//   public Executor executor();
// 
//   /**
//    * Returns the current channel.
//    *
//    * @return
//    */
//   public Channel channel();
// 
//   /**
//    * Returns all channels.
//    *
//    * @return
//    */
//   public Set<Channel> channels();
// 
//   public Map<Channel, String> channelMap();
// 
//   public <T> Attribute<T> attr(AttributeKey<T> key);
// 
//   public Room room();
// 
//   public RoomContext forChannel(Channel channel);
// }


import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.Executor;
import de.nixis.web.disco.dto.Participant;
import de.nixis.web.disco.room.Room;
import de.nixis.web.disco.room.RoomContext;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
package de.nixis.web.disco.room.impl;



/**
 *
 * @author nico.rehwaldt
 */
public class RoomContextImpl implements RoomContext {

  private final Executor executor;

  private final Room room;
  private final Channel channel;

  public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) {
    this(room, channelCtx.channel(), channelCtx.executor());
  }

  public RoomContextImpl(Room room, Channel channel, Executor executor) {
    this.room = room;
    this.executor = executor;
    this.channel = channel;
  }

  public Executor executor() {
    return executor;
  }

  public Channel channel() {
    return channel;
  }

  public Set<Channel> channels() {
    return room.channels();
  }

  public Map<Channel, String> channelMap() {
    return room.channelMap();
  }

  public Room room() {
    return room;
  }

  public <T> Attribute<T> attr(AttributeKey<T> key) {
// Path: server/src/main/java/de/nixis/web/disco/dto/Participant.java
// public class Participant implements Comparable<Participant> {
// 
//   private ObjectId id;
// 
//   private String name;
// 
//   public Participant(String name) {
//     this.name = name;
// 
//     this.id = new ObjectId();
//   }
// 
//   public Participant() {
//   }
// 
//   public String getId() {
//     return id.toString();
//   }
// 
//   public String getName() {
//     return name;
//   }
// 
//   public void setName(String name) {
//     this.name = name;
//   }
// 
//   public int compareTo(Participant o) {
//     return o.id.compareTo(id);
//   }
// }
// 
// Path: server/src/main/java/de/nixis/web/disco/room/Room.java
// public interface Room {
// 
//   public String id();
// 
//   public Map<Channel, String> channelMap();
// 
//   public Set<Channel> channels();
// 
//   public <T> Attribute<T> attr(AttributeKey<T> key);
// 
//   Map<String, Participant> participantsMap();
// }
// 
// Path: server/src/main/java/de/nixis/web/disco/room/RoomContext.java
// public interface RoomContext {
// 
//   public Executor executor();
// 
//   /**
//    * Returns the current channel.
//    *
//    * @return
//    */
//   public Channel channel();
// 
//   /**
//    * Returns all channels.
//    *
//    * @return
//    */
//   public Set<Channel> channels();
// 
//   public Map<Channel, String> channelMap();
// 
//   public <T> Attribute<T> attr(AttributeKey<T> key);
// 
//   public Room room();
// 
//   public RoomContext forChannel(Channel channel);
// }


// Path: server/src/main/java/de/nixis/web/disco/room/impl/RoomContextImpl.java
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.Executor;
import de.nixis.web.disco.dto.Participant;
import de.nixis.web.disco.room.Room;
import de.nixis.web.disco.room.RoomContext;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;

package de.nixis.web.disco.room.impl;



/**
 *
 * @author nico.rehwaldt
 */
public class RoomContextImpl implements RoomContext {

  private final Executor executor;

  private final Room room;
  private final Channel channel;

  public RoomContextImpl(ChannelHandlerContext channelCtx, Room room) {
    this(room, channelCtx.channel(), channelCtx.executor());
  }

  public RoomContextImpl(Room room, Channel channel, Executor executor) {
    this.room = room;
    this.executor = executor;
    this.channel = channel;
  }

  public Executor executor() {
    return executor;
  }

  public Channel channel() {
    return channel;
  }

  public Set<Channel> channels() {
    return room.channels();
  }

  public Map<Channel, String> channelMap() {
    return room.channelMap();
  }

  public Room room() {
    return room;
  }

  public <T> Attribute<T> attr(AttributeKey<T> key) {
    return room.attr(key);