diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..53704d66 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog + +## [v1.0.1](https://github.com/skyway/skyway-js-sdk/releases/tag/v1.0.1) - 2017-09-11 + +### Added + +- Change log + +### Fixed + +- Change timing of DataConnection 'open' event so that it can always be caught. ([PR #1](https://github.com/skyway/skyway-js-sdk/pull/1)) diff --git a/examples/p2p-textchat/script.js b/examples/p2p-textchat/script.js index 483ed6fe..41f4db17 100644 --- a/examples/p2p-textchat/script.js +++ b/examples/p2p-textchat/script.js @@ -21,7 +21,10 @@ $(function() { $('#pid').text(id); }); // Await connections from others - peer.on('connection', connect); + peer.on('connection', c => { + // Show connection when it is completely ready + c.on('open', () => connect(c)); + }); peer.on('error', err => console.log(err)); // Prepare file drop box. diff --git a/package.json b/package.json index f3be2850..04e58e4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "skyway", - "version": "1.0.0", + "version": "1.0.1", "description": "The JS client library for SkyWay", "main": "dist/skyway.js", "module": "src/peer.js", diff --git a/src/peer.js b/src/peer.js index a31754f7..6b20ed1b 100644 --- a/src/peer.js +++ b/src/peer.js @@ -555,11 +555,8 @@ class Peer extends EventEmitter { logger.log('DataConnection created in OFFER'); - // _addConnection() needs to be outside of the open event or else open won't fire. this._addConnection(offerMessage.src, connection); - connection.on(DataConnection.EVENTS.open.key, () => { - this.emit(Peer.EVENTS.connection.key, connection); - }); + this.emit(Peer.EVENTS.connection.key, connection); } else { logger.warn('Received malformed connection type: ', offerMessage.connectionType); }