Skip to content

Commit

Permalink
- Add dist files
Browse files Browse the repository at this point in the history
  • Loading branch information
cristijora committed Dec 22, 2020
1 parent 2aff8a2 commit 75c4fee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 7 additions & 5 deletions dist/voicenter-events-sdk.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var eventTypes = {
EXTENSION_EVENT: 'ExtensionEvent',
EXTENSION_UPDATED: 'ExtensionsUpdated',
ALL_EXTENSION_STATUS: 'AllExtensionsStatus',
CONNECT: 'connect',
CONNECT_ERROR: 'connect_error',
CONNECT_TIMEOUT: 'connect_timeout',
DISCONNECT: 'disconnect',
Expand Down Expand Up @@ -454,10 +455,11 @@ var queuesModule = {
};

function getServerWithHighestPriority(servers) {
// Highest priority server is the one with lowest Priority value
var chosenServer = null;
var maxPriority = -1;
var maxPriority = Number.MAX_SAFE_INTEGER;
servers.forEach(function (server) {
if (server.Priority > maxPriority) {
if (server.Priority < maxPriority) {
maxPriority = server.Priority;
chosenServer = server;
}
Expand Down Expand Up @@ -950,7 +952,7 @@ function () {
var server = null;

if (this.servers.length) {
server = this._findMaxPriorityServer() || this.servers[0];
server = this.servers[0];
}

this.server = server;
Expand All @@ -967,11 +969,11 @@ function () {
var currentServerPriority = this.server.Priority;
this.Logger.log("Failover -> Trying to find another server");

if (currentServerPriority === 0) {
if (currentServerPriority === this.servers.length - 1) {
return this._findMaxPriorityServer();
}

var nextServerPriority = currentServerPriority - 1;
var nextServerPriority = currentServerPriority + 1;
var nextServer = this.servers.find(function (server) {
return server.Priority === nextServerPriority;
});
Expand Down
12 changes: 7 additions & 5 deletions dist/voicenter-events-sdk.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ var eventTypes = {
EXTENSION_EVENT: 'ExtensionEvent',
EXTENSION_UPDATED: 'ExtensionsUpdated',
ALL_EXTENSION_STATUS: 'AllExtensionsStatus',
CONNECT: 'connect',
CONNECT_ERROR: 'connect_error',
CONNECT_TIMEOUT: 'connect_timeout',
DISCONNECT: 'disconnect',
Expand Down Expand Up @@ -450,10 +451,11 @@ var queuesModule = {
};

function getServerWithHighestPriority(servers) {
// Highest priority server is the one with lowest Priority value
var chosenServer = null;
var maxPriority = -1;
var maxPriority = Number.MAX_SAFE_INTEGER;
servers.forEach(function (server) {
if (server.Priority > maxPriority) {
if (server.Priority < maxPriority) {
maxPriority = server.Priority;
chosenServer = server;
}
Expand Down Expand Up @@ -946,7 +948,7 @@ function () {
var server = null;

if (this.servers.length) {
server = this._findMaxPriorityServer() || this.servers[0];
server = this.servers[0];
}

this.server = server;
Expand All @@ -963,11 +965,11 @@ function () {
var currentServerPriority = this.server.Priority;
this.Logger.log("Failover -> Trying to find another server");

if (currentServerPriority === 0) {
if (currentServerPriority === this.servers.length - 1) {
return this._findMaxPriorityServer();
}

var nextServerPriority = currentServerPriority - 1;
var nextServerPriority = currentServerPriority + 1;
var nextServer = this.servers.find(function (server) {
return server.Priority === nextServerPriority;
});
Expand Down
Loading

0 comments on commit 75c4fee

Please sign in to comment.