port not available"),
this._currentTransportIndex++,
s++;
continue
}
} else if ("webtransport" === a) {
if (this._debug("trying webtransport transport"),
this._transport = new WebtransportTransport(c,{
webtransport: globalThis.WebTransport,
decoder: this._codec,
encoder: this._codec
}),
!this._transport.supported()) {
this._debug("webtransport transport not available"),
this._currentTransportIndex++,
s++;
continue
}
} else if ("http_stream" === a) {
if (this._debug("trying http_stream transport"),
this._transport = new HttpStreamTransport(c,{
fetch: i,
readableStream: r,
emulationEndpoint: this._config.emulationEndpoint,
decoder: this._codec,
encoder: this._codec
}),
!this._transport.supported()) {
this._debug("http_stream transport not available"),
this._currentTransportIndex++,
s++;
continue
}
} else if ("sse" === a) {
if (this._debug("trying sse transport"),
this._transport = new SseTransport(c,{
eventsource: n,
fetch: i,
emulationEndpoint: this._config.emulationEndpoint
}),
!this._transport.supported()) {
this._debug("sse transport not available"),
this._currentTransportIndex++,
s++;
continue
}
} else {
if ("sockjs" !== a)
throw new Error("unknown transport " + a);
if (this._debug("trying sockjs"),
this._transport = new SockjsTransport(c,{
sockjs: t,
sockjsOptions: this._config.sockjsOptions
}),
!this._transport.supported()) {
this._debug("sockjs transport not available"),
this._currentTransportIndex++,
s++;
continue
}
}
break
}
} else {
if (startsWith(this._endpoint, "http"))
throw new Error("Provide explicit transport endpoints configuration in case of using HTTP (i.e. using array of TransportEndpoint instead of a single string), or use ws(s):// scheme in an endpoint if you aimed using WebSocket transport");
if (this._debug("client will use websocket"),
this._transport = new WebsocketTransport(this._endpoint,{
websocket: e
}),
!this._transport.supported())
throw new Error("WebSocket constructor not found, make sure it is available globally or passed as a dependency in Centrifuge options")
}
const s = this
, o = this._transport
, a = this._nextTransportId();
s._debug("id of transport", a);
let c = !1;
const l = [];
if (this._transport.emulation()) {
const e = s._sendConnect(!0);
l.push(e)
}
this._setNetworkEvents();
const u = this._codec.encodeCommands(l);
let h;
this._transportClosed = !1,
h = setTimeout((function() {
o.close()
}
), this._config.timeout),
this._transport.initialize(this._codecName(), {
onOpen: function() {
if (h && (clearTimeout(h),
h = null),
s._transportId != a)
return s._debug("open callback from non-actual transport"),
void o.close();
c = !0,
s._debug(o.subName(), "transport open"),
o.emulation() || (s._transportIsOpen = !0,
s._transportWasOpen = !0,
s.startBatching(),
s._sendConnect(!1),
s._sendSubscribeCommands(),
s.stopBatching(),
s.emit("__centrifuge_debug:connect_frame_sent", {}))
},
onError: function(e) {
s._transportId == a ? s._debug("transport level error", e) : s._debug("error callback from non-actual transport")
},
onClose: function(e) {
if (h && (clearTimeout(h),
h = null),
s._transportId != a)
return void s._debug("close callback from non-actual transport");
s._debug(o.subName(), "transport |