File tree 2 files changed +8
-6
lines changed
ts/packages/shell/src/renderer/src
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,7 @@ export function getWebSocketAPI(): ClientAPI {
29
29
if ( globalThis . webApi === undefined ) {
30
30
globalThis . webApi = webapi ;
31
31
32
- // TODO: update ws URI
33
- let url = window . location ;
34
- createWebSocket ( `ws://${ url . hostname } :3000` , true ) . then (
32
+ createWebSocket ( true ) . then (
35
33
( ws ) => ( globalThis . ws = ws ) ,
36
34
) ;
37
35
}
Original file line number Diff line number Diff line change @@ -230,9 +230,14 @@ function placeHolder(category: string, callback: any) {
230
230
}
231
231
232
232
export async function createWebSocket (
233
- endpoint : string = "ws://localhost:8080" ,
234
233
autoReconnect : boolean = true ,
235
234
) {
235
+ let url = window . location ;
236
+ let protocol = url . protocol . toLowerCase ( ) == "https" ? "wss" : "ws" ;
237
+ let port = url . hostname . toLocaleLowerCase ( ) == "localhost" ? ":3000" : "" ;
238
+
239
+ const endpoint = `${ protocol } ://${ url . hostname } ${ port } `
240
+
236
241
return new Promise < WebSocket | undefined > ( ( resolve ) => {
237
242
console . log ( `opening web socket to ${ endpoint } ` ) ;
238
243
const webSocket = new WebSocket ( endpoint ) ;
@@ -347,8 +352,7 @@ export async function createWebSocket(
347
352
348
353
// reconnect?
349
354
if ( autoReconnect ) {
350
- let url = window . location ;
351
- createWebSocket ( `ws://${ url . hostname } :3000` , true ) . then (
355
+ createWebSocket ( ) . then (
352
356
( ws ) => ( globalThis . ws = ws ) ,
353
357
) ;
354
358
}
You can’t perform that action at this time.
0 commit comments