mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-04-24 23:30:37 -05:00
Show an error message on connection failures
Apparently this code has been broken ever since we migrated to HTTPS.
This commit is contained in:
parent
7a3783d1c8
commit
05b9b19dcc
14
js/client.js
14
js/client.js
|
|
@ -732,8 +732,18 @@ function toId() {
|
|||
var constructSocket = function () {
|
||||
var protocol = (Config.server.port === 443 || Config.server.https) ? 'https' : 'http';
|
||||
Config.server.host = $.trim(Config.server.host);
|
||||
return new SockJS(protocol + '://' + Config.server.host + ':' +
|
||||
Config.server.port + Config.sockjsprefix, [], {timeout: 5 * 60 * 1000});
|
||||
try {
|
||||
return new SockJS(
|
||||
protocol + '://' + Config.server.host + ':' + Config.server.port + Config.sockjsprefix,
|
||||
[], {timeout: 5 * 60 * 1000}
|
||||
);
|
||||
} catch (err) {
|
||||
// The most common case this happens is if an HTTPS connection fails,
|
||||
// and we fall back to HTTP, which throws a SecurityError if the URL
|
||||
// is HTTPS
|
||||
self.trigger('init:connectionerror');
|
||||
return null;
|
||||
}
|
||||
};
|
||||
this.socket = constructSocket();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user