-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add tests, refactor code to exclude potential bugs, add doc
The API changed: WebChannel#open function returns a Promise instead of key. WebRTCService uses WebRTC Promise based API instead of callbacks (thats why webrtc-adapter dependecy was added. Because Chrome does not support yet WebRTC Promise based API). Some tests where refactored to be more simple and verbose. Many docs where added.
- Loading branch information
Showing
21 changed files
with
3,854 additions
and
1,458 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,72 @@ | ||
/** | ||
* This class represents a temporary state of a peer, while he is about to join | ||
* the web channel. During the joining process every peer in the web channel | ||
* and the joining peer have an instance of this class with the same `id` and | ||
* `intermediaryId` attribute values. After the joining process has been finished | ||
* regardless of success, these instances will be deleted. | ||
*/ | ||
class JoiningPeer { | ||
constructor (id, intermediaryId) { | ||
/** | ||
* The joining peer id. | ||
* | ||
* @type {string} | ||
*/ | ||
this.id = id | ||
|
||
/** | ||
* The id of the peer who invited the joining peer to the web channel. It is | ||
* a member of the web channel and called an intermediary peer between the | ||
* joining peer and the web channel. The same value for all instances. | ||
* | ||
* @type {string} | ||
*/ | ||
this.intermediaryId = intermediaryId | ||
|
||
/** | ||
* The channel between the joining peer and intermediary peer. It is null | ||
* for every peer, but the joining and intermediary peers. | ||
* | ||
* @type {ChannelInterface} | ||
*/ | ||
this.intermediaryChannel = null | ||
|
||
/** | ||
* This attribute is proper to each peer. Array of channels which will be | ||
* added to the current peer once the joining peer become the member of the | ||
* web channel. | ||
* | ||
* @type {Array[ChannelInterface]} | ||
*/ | ||
this.channelsToAdd = [] | ||
|
||
/** | ||
* This attribute is proper to each peer. Array of channels which will be | ||
* closed with the current peer once the joining peer become the member of the | ||
* web channel. | ||
* | ||
* @type {Array[ChannelInterface]} | ||
*/ | ||
this.channelsToRemove = [] | ||
} | ||
|
||
/** | ||
* Add channel to `channelsToAdd` array. | ||
* | ||
* @param {ChannelInterface} channel - Channel to add. | ||
*/ | ||
toAddList (channel) { | ||
this.channelsToAdd[this.channelsToAdd.length] = channel | ||
} | ||
|
||
/** | ||
* Add channel to `channelsToRemove` array | ||
* | ||
* @param {ChannelInterface} channel - Channel to add. | ||
*/ | ||
toRemoveList (channel) { | ||
this.channelsToAdd[this.channelsToAdd.length] = channel | ||
} | ||
|
||
} | ||
|
||
export default JoiningPeer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.