Skip to content

Commit

Permalink
added static list of all peers
Browse files Browse the repository at this point in the history
  • Loading branch information
inkrement committed Dec 30, 2013
1 parent a173d5c commit 88b084f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Messenger/src/peers/peer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ abstract class Peer{
///logging object
static final Logger parent_log = new Logger("Peer");

//list of all local peers
static Map<String, Peer> peers;

Logger log;

///number of all local peer instances
Expand Down Expand Up @@ -44,6 +47,9 @@ abstract class Peer{
Peer([String name="", Level logLevel=Level.FINE]){
this.name = (name.length < 1)?"peer" + (++num).toString():name; //set name of this peer instance

if(peers.keys.contains(this.name))
throw new StateError("peer with name ${this.name} already exists!");

//setup logger
hierarchicalLoggingEnabled = true;
log = new Logger("Peer.${this.runtimeType}.${this.name}");
Expand All @@ -61,6 +67,9 @@ abstract class Peer{
readyState=ReadyState.NEW;

log.info("new peer: #${num.toString()} ${this.name} ");

//add instance reference to peerlist
peers[this.name] = this;
}

/**
Expand Down

0 comments on commit 88b084f

Please sign in to comment.