UNPKG

react-device-portal

Version:
47 lines (44 loc) 1.77 kB
import { __extends, __awaiter, __generator } from '../_virtual/_tslib.js'; import { Peer } from './Peer.js'; var Initiator = /** @class */ (function (_super) { __extends(Initiator, _super); function Initiator() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.role = 'initiator'; return _this; } Initiator.prototype.connect = function () { return __awaiter(this, void 0, void 0, function () { var offer, answer; return __generator(this, function (_a) { switch (_a.label) { case 0: this.initializeConnectionAndChannel(); if (!this.connection) { return [2 /*return*/]; } return [4 /*yield*/, this.connection.createOffer()]; case 1: offer = _a.sent(); return [4 /*yield*/, this.setAndShareLocalDescription(offer)]; case 2: _a.sent(); return [4 /*yield*/, this.getRemoteDescription()]; case 3: answer = _a.sent(); if (!answer) { return [2 /*return*/]; } this.connection.setRemoteDescription(answer); return [4 /*yield*/, this.acquireIceCandidatesLoop()]; case 4: _a.sent(); return [2 /*return*/]; } }); }); }; return Initiator; }(Peer)); export { Initiator }; //# sourceMappingURL=Initiator.js.map