Skip to content

Commit

Permalink
added getters
Browse files Browse the repository at this point in the history
  • Loading branch information
michelle committed Apr 3, 2013
1 parent eda32ee commit a41dcd7
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 4 deletions.
57 changes: 56 additions & 1 deletion dist/peer.js
@@ -1,4 +1,4 @@
/*! peerjs.js build:0.2.0, development. Copyright(c) 2013 Michelle Bu <michelle@michellebu.com> */
/*! peerjs.js build:0.2.1, development. Copyright(c) 2013 Michelle Bu <michelle@michellebu.com> */
(function(exports){
var binaryFeatures = {};
binaryFeatures.useBlobBuilder = (function(){
Expand Down Expand Up @@ -1236,6 +1236,7 @@ function Peer(id, options) {
this.id = id;
this._init();
} else {
this.id = null;
this._getId();
}
};
Expand Down Expand Up @@ -1435,6 +1436,14 @@ Peer.prototype.connect = function(peer, options) {
return connectionInfo[1];
};

/**
* Return the peer id or null, if there's no id at the moment.
* Reasons for no id could be 'connect in progress' or 'disconnected'
*/
Peer.prototype.getId = function() {
return this.id;
};

/**
* Destroys the Peer: closes all active connections as well as the connection
* to the server.
Expand All @@ -1457,10 +1466,25 @@ Peer.prototype.destroy = function() {
Peer.prototype.disconnect = function() {
if (!this.disconnected) {
this._socket.close();
this.id = null;
this.disconnected = true;
}
};

/**
* Provides a clean method for checking if there's an active connection to the
* peer server.
*/
Peer.prototype.isConnected = function() {
return !this.disconnected;
};

/**
* Returns true if this peer is destroyed and can no longer be used.
*/
Peer.prototype.isDestroyed = function() {
return this.destroyed;
};

exports.Peer = Peer;
/**
Expand Down Expand Up @@ -1604,6 +1628,37 @@ DataConnection.prototype.send = function(data) {
}
}
};

/**
* Returns true if the DataConnection is open and able to send messages.
*/
DataConnection.prototype.isOpen = function() {
return this.open;
};

/**
* Gets the metadata associated with this DataConnection.
*/
DataConnection.prototype.getMetadata = function() {
return this.metadata;
};

/**
* Gets the label associated with this DataConnection.
*/
DataConnection.prototype.getLabel = function() {
return this.label;
};

/**
* Gets the brokering ID of the peer that you are connected with.
* Note that this ID may be out of date if the peer has disconnected from the
* server, so it's not recommended that you use this ID to identify this
* connection.
*/
DataConnection.prototype.getPeer = function() {
return this.peer;
};
/**
* Manages DataConnections between its peer and one other peer.
* Internally, manages PeerConnection.
Expand Down

0 comments on commit a41dcd7

Please sign in to comment.