Attempt websocket fix
This commit is contained in:
@@ -51,14 +51,21 @@ export class MudConnection extends EventEmitter {
|
||||
return;
|
||||
}
|
||||
|
||||
// Connect through the standalone WebSocket server on port 3001
|
||||
// Determine the WebSocket URL based on environment
|
||||
const wsProtocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
||||
const wsHost = `${window.location.hostname}:3001`;
|
||||
let wsUrl;
|
||||
|
||||
const url = `${wsProtocol}://${wsHost}/mud-ws?host=${encodeURIComponent(this.host)}&port=${this.port}&useSSL=${this.useSSL}`;
|
||||
console.log('Connecting to WebSocket server:', url);
|
||||
// In development, use port 3001
|
||||
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
|
||||
wsUrl = `${wsProtocol}://${window.location.hostname}:3001/mud-ws?host=${encodeURIComponent(this.host)}&port=${this.port}&useSSL=${this.useSSL}`;
|
||||
} else {
|
||||
// In production, use the same domain & port as the web app
|
||||
wsUrl = `${wsProtocol}://${window.location.host}/mud-ws?host=${encodeURIComponent(this.host)}&port=${this.port}&useSSL=${this.useSSL}`;
|
||||
}
|
||||
|
||||
this.webSocket = new WebSocket(url);
|
||||
console.log('Connecting to WebSocket server:', wsUrl);
|
||||
|
||||
this.webSocket = new WebSocket(wsUrl);
|
||||
|
||||
this.webSocket.binaryType = 'arraybuffer';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user