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,33 +304,34 @@ function connect() {
socket.binaryType = 'arraybuffer';
socket.onopen = () => {
// Wait for WebAssembly module to be ready
WallixModule.then((module) => {
const canvas = document.getElementById('canvas');
const gd = newRdpGraphics2D(canvas, module);
const config = {
width: 1024,
height: 768,
username: '',
password: '',
domain: '',
bpp: 32,
verbosity: 0
};
rdpclient = new module.RdpClient(gd, config);
rdpclient.writeFirstPacket();
sendData();
connected = true;
document.getElementById('connectBtn').disabled = true;
document.getElementById('disconnectBtn').disabled = false;
// Hide loading message
document.getElementById('rdp_loading').style.display = 'none';
showNotification('RDP session connected', 'success');
}).catch((error) => {
console.error('Failed to initialize WebAssembly module:', error);
showNotification('Failed to initialize RDP client', 'danger');
// Check if WebAssembly module functions are available
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 gd = newRdpGraphics2D(canvas, Module);
const config = {
width: 1024,
height: 768,
username: '',
password: '',
domain: '',
bpp: 32,
verbosity: 0
};
rdpclient = new Module.RdpClient(gd, config);
rdpclient.writeFirstPacket();
sendData();
connected = true;
document.getElementById('connectBtn').disabled = true;
document.getElementById('disconnectBtn').disabled = false;
// Hide loading message
document.getElementById('rdp_loading').style.display = 'none';
showNotification('RDP session connected', 'success');
};
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