Skip to content

Commit

Permalink
Fix Jingle session direction translation
Browse files Browse the repository at this point in the history
  • Loading branch information
legastero committed Jan 2, 2019
1 parent 20b61b7 commit be6962c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/jingle/FileTransferSession.js
Expand Up @@ -241,7 +241,7 @@ export default class FileTransferSession extends ICESession {
this.role = 'responder';
this.state = 'pending';

const json = convertRequestToIntermediate(changes, this.role);
const json = convertRequestToIntermediate(changes, this.peerRole);
const sdp = exportToSDP(json);
const desc = changes.contents[0].application;

Expand Down
6 changes: 3 additions & 3 deletions src/jingle/ICESession.js
Expand Up @@ -130,7 +130,7 @@ export default class ICESession extends BaseSession {
onSessionAccept(changes, cb) {
this.state = 'active';

const json = convertRequestToIntermediate(changes, this.role);
const json = convertRequestToIntermediate(changes, this.peerRole);
const sdp = exportToSDP(json);
this.pc.setRemoteDescription({ type: 'answer', sdp }).then(
() => {
Expand Down Expand Up @@ -299,7 +299,7 @@ export default class ICESession extends BaseSession {
*/
maybeRestartIce() {
// only initiators do an ice-restart to avoid conflicts.
if (this.role !== 'initiator') {
if (!this.isInitiator) {
return;
}
if (this._maybeRestartingIce !== undefined) {
Expand All @@ -316,7 +316,7 @@ export default class ICESession extends BaseSession {
/* actually do an ice restart */
restartIce() {
// only initiators do an ice-restart to avoid conflicts.
if (this.role !== 'initiator') {
if (!this.isInitiator) {
return;
}
if (this._maybeRestartingIce !== undefined) {
Expand Down
7 changes: 4 additions & 3 deletions src/jingle/MediaSession.js
Expand Up @@ -45,7 +45,6 @@ export default class MediaSession extends ICESession {
}

this._ringing = false;
this.role = 'responder';
}

// ----------------------------------------------------------------
Expand Down Expand Up @@ -94,6 +93,8 @@ export default class MediaSession extends ICESession {

this.state = 'active';

this.role = 'resonder';

this.pc
.createAnswer(opts)
.then(answer => {
Expand Down Expand Up @@ -202,9 +203,9 @@ export default class MediaSession extends ICESession {
this._log('info', 'Initiating incoming session');

this.state = 'pending';

this.role = 'responder';
const json = convertRequestToIntermediate(changes, this.role);

const json = convertRequestToIntermediate(changes, this.peerRole);
json.media.forEach(media => {
if (!media.streams) {
media.streams = [{ stream: 'legacy', track: media.kind }];
Expand Down
10 changes: 9 additions & 1 deletion src/jingle/Session.js
Expand Up @@ -27,7 +27,7 @@ export default class JingleSession extends WildEmitter {

this.sid = opts.sid || uuid.v4();
this.peerID = opts.peerID;
this.isInitiator = opts.initiator || false;
this.role = opts.initiator ? 'initiator' : 'responder';
this.parent = opts.parent;
this.state = 'starting';
this.connectionState = 'starting';
Expand Down Expand Up @@ -58,6 +58,14 @@ export default class JingleSession extends WildEmitter {
});
}

get isInitiator() {
return this.role === 'initiator';
}

get peerRole() {
return this.isInitiator ? 'responder' : 'initiator';
}

get state() {
return this._sessionState;
}
Expand Down

0 comments on commit be6962c

Please sign in to comment.