Fix WebAssembly module access - use synchronous Module object

- WallixModule is not a Promise, Module is the global WebAssembly object
- Check if newRdpGraphics2D is defined before using it
- Use Module.RdpClient directly like in rdpwasm/mstsc.js
- Rebuild project to embed updated HTML template
parent 585c3956
...@@ -304,10 +304,16 @@ function connect() { ...@@ -304,10 +304,16 @@ function connect() {
socket.binaryType = 'arraybuffer'; socket.binaryType = 'arraybuffer';
socket.onopen = () => { socket.onopen = () => {
// Wait for WebAssembly module to be ready // Check if WebAssembly module functions are available
WallixModule.then((module) => { if (typeof newRdpGraphics2D === 'undefined') {
console.error('WebAssembly RDP functions not loaded');
showNotification('Failed to load RDP client', 'danger');
disconnect();
return;
}
const canvas = document.getElementById('canvas'); const canvas = document.getElementById('canvas');
const gd = newRdpGraphics2D(canvas, module); const gd = newRdpGraphics2D(canvas, Module);
const config = { const config = {
width: 1024, width: 1024,
height: 768, height: 768,
...@@ -317,7 +323,7 @@ function connect() { ...@@ -317,7 +323,7 @@ function connect() {
bpp: 32, bpp: 32,
verbosity: 0 verbosity: 0
}; };
rdpclient = new module.RdpClient(gd, config); rdpclient = new Module.RdpClient(gd, config);
rdpclient.writeFirstPacket(); rdpclient.writeFirstPacket();
sendData(); sendData();
connected = true; connected = true;
...@@ -326,11 +332,6 @@ function connect() { ...@@ -326,11 +332,6 @@ function connect() {
// Hide loading message // Hide loading message
document.getElementById('rdp_loading').style.display = 'none'; document.getElementById('rdp_loading').style.display = 'none';
showNotification('RDP session connected', 'success'); showNotification('RDP session connected', 'success');
}).catch((error) => {
console.error('Failed to initialize WebAssembly module:', error);
showNotification('Failed to initialize RDP client', 'danger');
disconnect();
});
}; };
socket.onmessage = (event) => { socket.onmessage = (event) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment