Addresses #23
This commit is contained in:
parent
5d358ce71f
commit
a17fe6380a
15
README.md
15
README.md
@ -55,6 +55,21 @@ var server = new PeerServer({
|
||||
});
|
||||
```
|
||||
|
||||
### Events
|
||||
|
||||
The `'connection'` event is emitted when a peer connects to the server.
|
||||
|
||||
```javascript
|
||||
PeerServer#on('connection', function(id) { ... })
|
||||
```
|
||||
|
||||
The `'disconnect'` event is emitted when a peer disconnects from the server or
|
||||
when the peer can no longer be reached.
|
||||
|
||||
```javascript
|
||||
PeerServer#on('disconnect', function(id) { ... })
|
||||
```
|
||||
|
||||
## Problems?
|
||||
|
||||
Discuss PeerJS on our Google Group:
|
||||
|
@ -79,6 +79,9 @@ PeerServer.prototype._initializeWSS = function() {
|
||||
self._clients[key][id] = { token: token, ip: ip };
|
||||
self._ips[ip]++;
|
||||
socket.send(JSON.stringify({ type: 'OPEN' }));
|
||||
// We're going to emit here, because for XHR we don't *know* when someone
|
||||
// disconnects.
|
||||
self.emit('connection', id);
|
||||
}
|
||||
self._configureWS(socket, key, id, token);
|
||||
} else {
|
||||
@ -345,6 +348,7 @@ PeerServer.prototype._removePeer = function(key, id) {
|
||||
if (this._clients[key] && this._clients[key][id]) {
|
||||
this._ips[this._clients[key][id].ip]--;
|
||||
delete this._clients[key][id];
|
||||
this.emit('disconnect', id);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user