|
@@ -46,16 +46,19 @@ export default class XmppConnection extends Listenable {
|
46
|
46
|
* It will enable automatically by default if supported by the XMPP server.
|
47
|
47
|
* @param {Number} [options.websocketKeepAlive=60000] - The websocket keep alive interval.
|
48
|
48
|
* It's the interval + a up to a minute of jitter. Pass -1 to disable.
|
49
|
|
- * The keep alive is HTTP GET request to the {@link options.serviceUrl}.
|
|
49
|
+ * The keep alive is HTTP GET request to {@link options.serviceUrl} or to {@link options.websocketKeepAliveUrl}.
|
|
50
|
+ * @param {Number} [options.websocketKeepAliveUrl] - The websocket keep alive url to use if any,
|
|
51
|
+ * if missing the serviceUrl url will be used.
|
50
|
52
|
* @param {Object} [options.xmppPing] - The xmpp ping settings.
|
51
|
53
|
*/
|
52
|
|
- constructor({ enableWebsocketResume, websocketKeepAlive, serviceUrl, shard, xmppPing }) {
|
|
54
|
+ constructor({ enableWebsocketResume, websocketKeepAlive, websocketKeepAliveUrl, serviceUrl, shard, xmppPing }) {
|
53
|
55
|
super();
|
54
|
56
|
this._options = {
|
55
|
57
|
enableWebsocketResume: typeof enableWebsocketResume === 'undefined' ? true : enableWebsocketResume,
|
56
|
58
|
pingOptions: xmppPing,
|
57
|
59
|
shard,
|
58
|
|
- websocketKeepAlive: typeof websocketKeepAlive === 'undefined' ? 60 * 1000 : Number(websocketKeepAlive)
|
|
60
|
+ websocketKeepAlive: typeof websocketKeepAlive === 'undefined' ? 60 * 1000 : Number(websocketKeepAlive),
|
|
61
|
+ websocketKeepAliveUrl
|
59
|
62
|
};
|
60
|
63
|
|
61
|
64
|
this._stropheConn = new Strophe.Connection(serviceUrl);
|
|
@@ -404,8 +407,9 @@ export default class XmppConnection extends Listenable {
|
404
|
407
|
* @returns {Promise}
|
405
|
408
|
*/
|
406
|
409
|
_keepAliveAndCheckShard() {
|
407
|
|
- const { shard } = this._options;
|
408
|
|
- const url = this.service.replace('wss://', 'https://').replace('ws://', 'http://');
|
|
410
|
+ const { shard, websocketKeepAliveUrl } = this._options;
|
|
411
|
+ const url = websocketKeepAliveUrl ? websocketKeepAliveUrl
|
|
412
|
+ : this.service.replace('wss://', 'https://').replace('ws://', 'http://');
|
409
|
413
|
|
410
|
414
|
return fetch(url)
|
411
|
415
|
.then(response => {
|