peer-data
Advanced tools
Comparing version 3.0.6 to 3.0.7
@@ -26,3 +26,3 @@ import { EventHandler } from './EventHandler'; | ||
private onMessage(event); | ||
private onTrack(event); | ||
private dispatchRemoteStream(event); | ||
} |
@@ -20,3 +20,3 @@ import * as tslib_1 from "tslib"; | ||
this.peer.ondatachannel = this.onDataChannel.bind(this); | ||
this.peer.ontrack = this.onTrack.bind(this); | ||
this.peer.ontrack = this.dispatchRemoteStream.bind(this); | ||
var stream = this.room.getStream(); | ||
@@ -33,24 +33,23 @@ if (stream instanceof MediaStream) { | ||
var _this = this; | ||
var offerAnswerOptions; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
offerAnswerOptions = { | ||
offerToReceiveAudio: 1, | ||
offerToReceiveVideo: 1, | ||
}; | ||
if (!this.remoteDesc) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.peer | ||
.setRemoteDescription(this.remoteDesc) | ||
.then(function (_) { return _this.peer.createAnswer(); }) | ||
.then(function (_) { return _this.peer.createAnswer(offerAnswerOptions); }) | ||
.then(function (desc) { return _this.peer.setLocalDescription(desc); }) | ||
.then(function (_) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, EventDispatcher.getInstance().dispatch('send', { | ||
type: SignalingEventType.ANSWER, | ||
caller: null, | ||
callee: { id: this.id }, | ||
room: { id: this.room.getId() }, | ||
payload: this.peer.localDescription, | ||
})]; | ||
}); | ||
.then(function (_) { return EventDispatcher.getInstance().dispatch('send', { | ||
type: SignalingEventType.ANSWER, | ||
caller: null, | ||
callee: { id: _this.id }, | ||
room: { id: _this.room.getId() }, | ||
payload: _this.peer.localDescription, | ||
}); }) | ||
.then(function (_) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this]; | ||
}); }); })]; | ||
.then(function (_) { return _this; })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -61,18 +60,12 @@ case 2: | ||
return [4 /*yield*/, this.peer | ||
.createOffer() | ||
.createOffer(offerAnswerOptions) | ||
.then(function (desc) { return _this.peer.setLocalDescription(desc); }) | ||
.then(function (_) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, EventDispatcher.getInstance().dispatch('send', { | ||
type: SignalingEventType.OFFER, | ||
caller: null, | ||
callee: { id: this.id }, | ||
room: { id: this.room.getId() }, | ||
payload: this.peer.localDescription, | ||
})]; | ||
}); | ||
.then(function (_) { return EventDispatcher.getInstance().dispatch('send', { | ||
type: SignalingEventType.OFFER, | ||
caller: null, | ||
callee: { id: _this.id }, | ||
room: { id: _this.room.getId() }, | ||
payload: _this.peer.localDescription, | ||
}); }) | ||
.then(function (_) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this]; | ||
}); }); })]; | ||
.then(function (_) { return _this; })]; | ||
case 3: return [2 /*return*/, _a.sent()]; | ||
@@ -164,3 +157,3 @@ } | ||
}; | ||
Participant.prototype.onTrack = function (event) { | ||
Participant.prototype.dispatchRemoteStream = function (event) { | ||
this.dispatcher.dispatch('track', event); | ||
@@ -167,0 +160,0 @@ }; |
@@ -26,3 +26,3 @@ import { EventHandler } from './EventHandler'; | ||
private onMessage(event); | ||
private onTrack(event); | ||
private dispatchRemoteStream(event); | ||
} |
@@ -22,3 +22,3 @@ "use strict"; | ||
this.peer.ondatachannel = this.onDataChannel.bind(this); | ||
this.peer.ontrack = this.onTrack.bind(this); | ||
this.peer.ontrack = this.dispatchRemoteStream.bind(this); | ||
var stream = this.room.getStream(); | ||
@@ -35,24 +35,23 @@ if (stream instanceof MediaStream) { | ||
var _this = this; | ||
var offerAnswerOptions; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
offerAnswerOptions = { | ||
offerToReceiveAudio: 1, | ||
offerToReceiveVideo: 1, | ||
}; | ||
if (!this.remoteDesc) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.peer | ||
.setRemoteDescription(this.remoteDesc) | ||
.then(function (_) { return _this.peer.createAnswer(); }) | ||
.then(function (_) { return _this.peer.createAnswer(offerAnswerOptions); }) | ||
.then(function (desc) { return _this.peer.setLocalDescription(desc); }) | ||
.then(function (_) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, EventDispatcher_1.EventDispatcher.getInstance().dispatch('send', { | ||
type: SignalingEventType_1.SignalingEventType.ANSWER, | ||
caller: null, | ||
callee: { id: this.id }, | ||
room: { id: this.room.getId() }, | ||
payload: this.peer.localDescription, | ||
})]; | ||
}); | ||
.then(function (_) { return EventDispatcher_1.EventDispatcher.getInstance().dispatch('send', { | ||
type: SignalingEventType_1.SignalingEventType.ANSWER, | ||
caller: null, | ||
callee: { id: _this.id }, | ||
room: { id: _this.room.getId() }, | ||
payload: _this.peer.localDescription, | ||
}); }) | ||
.then(function (_) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this]; | ||
}); }); })]; | ||
.then(function (_) { return _this; })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -63,18 +62,12 @@ case 2: | ||
return [4 /*yield*/, this.peer | ||
.createOffer() | ||
.createOffer(offerAnswerOptions) | ||
.then(function (desc) { return _this.peer.setLocalDescription(desc); }) | ||
.then(function (_) { return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, EventDispatcher_1.EventDispatcher.getInstance().dispatch('send', { | ||
type: SignalingEventType_1.SignalingEventType.OFFER, | ||
caller: null, | ||
callee: { id: this.id }, | ||
room: { id: this.room.getId() }, | ||
payload: this.peer.localDescription, | ||
})]; | ||
}); | ||
.then(function (_) { return EventDispatcher_1.EventDispatcher.getInstance().dispatch('send', { | ||
type: SignalingEventType_1.SignalingEventType.OFFER, | ||
caller: null, | ||
callee: { id: _this.id }, | ||
room: { id: _this.room.getId() }, | ||
payload: _this.peer.localDescription, | ||
}); }) | ||
.then(function (_) { return tslib_1.__awaiter(_this, void 0, void 0, function () { return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this]; | ||
}); }); })]; | ||
.then(function (_) { return _this; })]; | ||
case 3: return [2 /*return*/, _a.sent()]; | ||
@@ -166,3 +159,3 @@ } | ||
}; | ||
Participant.prototype.onTrack = function (event) { | ||
Participant.prototype.dispatchRemoteStream = function (event) { | ||
this.dispatcher.dispatch('track', event); | ||
@@ -169,0 +162,0 @@ }; |
{ | ||
"name": "peer-data", | ||
"version": "3.0.6", | ||
"version": "3.0.7", | ||
"description": "PeerData - library for files, media streaming/sharing using WebRTC", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
444294
1418