Skip to content

Commit

Permalink
Adding back accidentally removed code
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Wang committed Nov 29, 2024
1 parent 0496709 commit 3a573fb
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 5 deletions.
2 changes: 1 addition & 1 deletion release/connect-streams-dr-min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion release/connect-streams-dr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion release/connect-streams-min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion release/connect-streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -10827,9 +10827,10 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
this.agentUpdateSubscriber = this.bus.subscribe(connect.AgentEvents.UPDATE, connect.hitch(this, this.updateAgentData));
};
AgentDataProvider.prototype.updateAgentData = function (agentData) {
var _connect$agent;
var oldAgentData = this.agentData;
this.agentData = agentData;
if (oldAgentData == null) {
if (!((_connect$agent = connect.agent) !== null && _connect$agent !== void 0 && _connect$agent.initialized)) {
connect.agent.initialized = true;
this.bus.trigger(connect.AgentEvents.INIT, new connect.Agent());
}
Expand Down
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ connect.core.setSoftphoneUserMediaStream = function (stream) {
var oldAgentData = this.agentData;
this.agentData = agentData;

if (oldAgentData == null) {
if (!connect.agent?.initialized) {
connect.agent.initialized = true;
this.bus.trigger(connect.AgentEvents.INIT, new connect.Agent());
}
Expand Down
47 changes: 47 additions & 0 deletions test/unit/global-resiliency.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,5 +519,52 @@ describe('Global Resiliency', function () {

assert.isFalse(didSwitch);
});

it("should call _refreshRtcPeerConnectionFactory when initialize region", function () {
const fakeGrProxyConduit = {
setActiveConduit: sinon.stub(),
getActiveConduit: sinon.stub().returns({ keepalivemanager: 0, sendUpstream: sinon.stub() }),
getInactiveConduit: sinon.stub().returns({ keepalivemanager: 0, sendUpstream: sinon.stub() }),
};

connect.core.softphoneManager = { _refreshRtcPeerConnectionFactory: sinon.stub() }

const region = 'us-east-1';

const oldClient = connect.core.client;
const oldMasterClient = connect.core.masterClient;

connect.globalResiliency._initializeActiveRegion(fakeGrProxyConduit, region);

connect.core.masterClient = oldMasterClient;
connect.core.client = oldClient;

assert.isTrue(connect.core.softphoneManager._refreshRtcPeerConnectionFactory.calledOnce);
});

it("should call _initiateRtcPeerConnectionManager when initialize region and instance is allowlisted for softphone persistent connection feature", function () {
const fakeGrProxyConduit = {
setActiveConduit: sinon.stub(),
getActiveConduit: sinon.stub().returns({ keepalivemanager: 0, sendUpstream: sinon.stub() }),
getInactiveConduit: sinon.stub().returns({ keepalivemanager: 0, sendUpstream: sinon.stub() }),
};

connect.core._allowSoftphonePersistentConnection = true;
connect.core.softphoneManager = { _initiateRtcPeerConnectionManager: sinon.stub() }

const region = 'us-east-1';

const oldClient = connect.core.client;
const oldMasterClient = connect.core.masterClient;

connect.globalResiliency._initializeActiveRegion(fakeGrProxyConduit, region);

// Need to reset these or softphone unit test will fail due to missing client
connect.core.masterClient = oldMasterClient;
connect.core.client = oldClient;
connect.core._allowSoftphonePersistentConnection = null;

assert.isTrue(connect.core.softphoneManager._initiateRtcPeerConnectionManager.calledOnce);
});
});
});

0 comments on commit 3a573fb

Please sign in to comment.