mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-02 18:15:56 +00:00
Merge branch 'develop' of https://github.com/ripple/ripple-lib into develop
This commit is contained in:
@@ -163,6 +163,11 @@ Server.prototype.connect = function() {
|
||||
if (this._ws) this._ws.close();
|
||||
|
||||
var WebSocket = Server.websocketConstructor();
|
||||
|
||||
if (!WebSocket) {
|
||||
throw new Error("No websocket support detected!");
|
||||
}
|
||||
|
||||
var ws = this._ws = new WebSocket(this._opts.url);
|
||||
|
||||
this._shouldConnect = true;
|
||||
|
||||
@@ -1,6 +1,40 @@
|
||||
// If there is no WebSocket, try MozWebSocket (support for some old browsers)
|
||||
try {
|
||||
module.exports = WebSocket
|
||||
module.exports = WebSocket;
|
||||
} catch(err) {
|
||||
module.exports = MozWebSocket
|
||||
module.exports = MozWebSocket;
|
||||
}
|
||||
|
||||
// Some versions of Safari Mac 5 and Safari iOS 4 seem to support websockets,
|
||||
// but can't communicate with websocketpp, which is what rippled uses.
|
||||
//
|
||||
// Note that we check for both the WebSocket protocol version the browser seems
|
||||
// to implement as well as the user agent etc. The reason is that we want to err
|
||||
// on the side of trying to connect since we don't want to accidentally disable
|
||||
// a browser that would normally work fine.
|
||||
var match, versionRegexp = /Version\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//;
|
||||
if (
|
||||
// Is browser
|
||||
"object" === typeof navigator &&
|
||||
"string" === typeof navigator.userAgent &&
|
||||
// Is Safari
|
||||
(match = versionRegexp.exec(navigator.userAgent)) &&
|
||||
// And uses the old websocket protocol
|
||||
2 === window.WebSocket.CLOSED
|
||||
) {
|
||||
// Is iOS
|
||||
if (/iP(hone|od|ad)/.test(navigator.platform)) {
|
||||
// Below version 5 is broken
|
||||
if (+match[1] < 5) {
|
||||
module.exports = void(0);
|
||||
}
|
||||
// Is any other Mac OS
|
||||
// If you want to refactor this code, be careful, iOS user agents contain the
|
||||
// string "like Mac OS X".
|
||||
} else if (navigator.appVersion.indexOf("Mac") !== -1) {
|
||||
// Below version 6 is broken
|
||||
if (+match[1] < 6) {
|
||||
module.exports = void(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user