Fix RDP page connection by adding keyboard and mouse event handling from example.html

- Added WallixModule initialization with logging
- Integrated keyboard classes (Keyboard, EmulatedKeyboard, UnicodeKeyboard) from example
- Added mouse event handling functions
- Implemented event listeners for canvas and focus
- Updated connect function to properly set up RDP client with input handling
- Added updateInput and keyboard layout management
- Cleaned up event listeners on disconnect
parent cf9c5ea9
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
- the Makefile is generated by the script configure.sh - the Makefile is generated by the script configure.sh
- in wssshd webinterface, the vnc page and the rdp page uses different websocket implementation, looks at the specifics of web.c and vnc.c or rdp.c, the file websocket.c is user ALSO for the websockets in the communication port with wssshc and wsssht, if you modify something for vnc or rdp or anything in the web interface, don't break the implementation for the wssshc-wssshd-wsssht communication channel/protocol - in wssshd webinterface, the vnc page and the rdp page uses different websocket implementation, looks at the specifics of web.c and vnc.c or rdp.c, the file websocket.c is user ALSO for the websockets in the communication port with wssshc and wsssht, if you modify something for vnc or rdp or anything in the web interface, don't break the implementation for the wssshc-wssshd-wsssht communication channel/protocol
- vnc page on wssshd uses the project noVNC - vnc page on wssshd uses the project noVNC
- rdp page on wssshd uses rdp.wasm, project page: https://github.com/sitepi/rdp.wasm - rdp page on wssshd uses rdp.wasm, project page: https://github.com/sitepi/rdp.wasm, you can check the example page at https://github.com/sitepi/rdp.wasm/blob/main/example.html
...@@ -2,3 +2,5 @@ ...@@ -2,3 +2,5 @@
- the script embed_assets.sh is launched by the Makefile - the script embed_assets.sh is launched by the Makefile
- the Makefile is generated by the script configure.sh - the Makefile is generated by the script configure.sh
- in wssshd webinterface, the vnc page and the rdp page uses different websocket implementation, looks at the specifics of web.c and vnc.c or rdp.c, the file websocket.c is user ALSO for the websockets in the communication port with wssshc and wsssht, if you modify something for vnc or rdp or anything in the web interface, don't break the implementation for the wssshc-wssshd-wsssht communication channel/protocol - in wssshd webinterface, the vnc page and the rdp page uses different websocket implementation, looks at the specifics of web.c and vnc.c or rdp.c, the file websocket.c is user ALSO for the websockets in the communication port with wssshc and wsssht, if you modify something for vnc or rdp or anything in the web interface, don't break the implementation for the wssshc-wssshd-wsssht communication channel/protocol
- vnc page on wssshd uses the project noVNC
- rdp page on wssshd uses rdp.wasm, project page: https://github.com/sitepi/rdp.wasm
...@@ -1549,6 +1549,10 @@ const char *rdp_rdp_wasm_js = ...@@ -1549,6 +1549,10 @@ const char *rdp_rdp_wasm_js =
" define([], function() { return WallixModule; });\n" " define([], function() { return WallixModule; });\n"
"else if (typeof exports === 'object')\n" "else if (typeof exports === 'object')\n"
" exports[\"WallixModule\"] = WallixModule;\n" " exports[\"WallixModule\"] = WallixModule;\n"
"else {\n"
" window.WallixModule = WallixModule;\n"
" window.Module = WallixModule;\n"
"}\n"
"\n" "\n"
; ;
if (strcmp(path, "/rdpwasm/rdp.wasm.js") == 0) { if (strcmp(path, "/rdpwasm/rdp.wasm.js") == 0) {
...@@ -2975,7 +2979,7 @@ const char *rdp_rdp_graphics_js = ...@@ -2975,7 +2979,7 @@ const char *rdp_rdp_graphics_js =
" return ctx ? createCtx(ctx, newRdpPointer(canvasElement, module)) : undefined;\n" " return ctx ? createCtx(ctx, newRdpPointer(canvasElement, module)) : undefined;\n"
"};\n" "};\n"
"\n" "\n"
"try {\n" "if (typeof module !== 'undefined' && module.exports) {\n"
" module.exports.newRdpGraphics2D = newRdpGraphics2D;\n" " module.exports.newRdpGraphics2D = newRdpGraphics2D;\n"
" module.exports.newRdpGraphicsGL = newRdpGraphicsGL;\n" " module.exports.newRdpGraphicsGL = newRdpGraphicsGL;\n"
" module.exports.newRdpGraphicsGL2 = newRdpGraphicsGL2;\n" " module.exports.newRdpGraphicsGL2 = newRdpGraphicsGL2;\n"
...@@ -2984,9 +2988,15 @@ const char *rdp_rdp_graphics_js = ...@@ -2984,9 +2988,15 @@ const char *rdp_rdp_graphics_js =
" module.exports.newRdpGL = newRdpGL;\n" " module.exports.newRdpGL = newRdpGL;\n"
" module.exports.newRdpGL2 = newRdpGL2;\n" " module.exports.newRdpGL2 = newRdpGL2;\n"
" module.exports.newRdpPointer = newRdpPointer;\n" " module.exports.newRdpPointer = newRdpPointer;\n"
"}\n" "} else {\n"
"catch (e) {\n" " window.newRdpGraphics2D = newRdpGraphics2D;\n"
" // module not found\n" " window.newRdpGraphicsGL = newRdpGraphicsGL;\n"
" window.newRdpGraphicsGL2 = newRdpGraphicsGL2;\n"
" window.newRdpGraphics = newRdpGraphics;\n"
" window.newRdpCanvas = newRdpCanvas;\n"
" window.newRdpGL = newRdpGL;\n"
" window.newRdpGL2 = newRdpGL2;\n"
" window.newRdpPointer = newRdpPointer;\n"
"}\n" "}\n"
"\n" "\n"
; ;
...@@ -103,7 +103,7 @@ function updateClients() { ...@@ -103,7 +103,7 @@ function updateClients() {
actionsHtml += `<a href="/vnc/${clientId}" class="btn btn-info btn-sm me-1"><i class="fas fa-desktop"></i> VNC</a>`; actionsHtml += `<a href="/vnc/${clientId}" class="btn btn-info btn-sm me-1"><i class="fas fa-desktop"></i> VNC</a>`;
} }
if (services.includes('rdp')) { if (services.includes('rdp')) {
actionsHtml += `<a href="/rdp/${clientId}" class="btn btn-primary btn-sm me-1"><i class="fas fa-windows"></i> RDP</a>`; actionsHtml += `<a href="/rdp/${clientId}" class="btn btn-primary btn-sm me-1"><i class="fas fa-desktop"></i> RDP</a>`;
} }
clientListHtml += ` clientListHtml += `
<div class="col-md-4 mb-3"> <div class="col-md-4 mb-3">
......
This diff is collapsed.
...@@ -19,3 +19,7 @@ else if (typeof define === 'function' && define['amd']) ...@@ -19,3 +19,7 @@ else if (typeof define === 'function' && define['amd'])
define([], function() { return WallixModule; }); define([], function() { return WallixModule; });
else if (typeof exports === 'object') else if (typeof exports === 'object')
exports["WallixModule"] = WallixModule; exports["WallixModule"] = WallixModule;
else {
window.WallixModule = WallixModule;
window.Module = WallixModule;
}
...@@ -1417,7 +1417,7 @@ const newRdpGraphics = function(canvasElement, module, ropError) { ...@@ -1417,7 +1417,7 @@ const newRdpGraphics = function(canvasElement, module, ropError) {
return ctx ? createCtx(ctx, newRdpPointer(canvasElement, module)) : undefined; return ctx ? createCtx(ctx, newRdpPointer(canvasElement, module)) : undefined;
}; };
try { if (typeof module !== 'undefined' && module.exports) {
module.exports.newRdpGraphics2D = newRdpGraphics2D; module.exports.newRdpGraphics2D = newRdpGraphics2D;
module.exports.newRdpGraphicsGL = newRdpGraphicsGL; module.exports.newRdpGraphicsGL = newRdpGraphicsGL;
module.exports.newRdpGraphicsGL2 = newRdpGraphicsGL2; module.exports.newRdpGraphicsGL2 = newRdpGraphicsGL2;
...@@ -1426,7 +1426,13 @@ try { ...@@ -1426,7 +1426,13 @@ try {
module.exports.newRdpGL = newRdpGL; module.exports.newRdpGL = newRdpGL;
module.exports.newRdpGL2 = newRdpGL2; module.exports.newRdpGL2 = newRdpGL2;
module.exports.newRdpPointer = newRdpPointer; module.exports.newRdpPointer = newRdpPointer;
} } else {
catch (e) { window.newRdpGraphics2D = newRdpGraphics2D;
// module not found window.newRdpGraphicsGL = newRdpGraphicsGL;
window.newRdpGraphicsGL2 = newRdpGraphicsGL2;
window.newRdpGraphics = newRdpGraphics;
window.newRdpCanvas = newRdpCanvas;
window.newRdpGL = newRdpGL;
window.newRdpGL2 = newRdpGL2;
window.newRdpPointer = newRdpPointer;
} }
...@@ -437,7 +437,40 @@ function connect() { ...@@ -437,7 +437,40 @@ function connect() {
rfb.addEventListener('securityfailure', (e) => { rfb.addEventListener('securityfailure', (e) => {
console.error('VNC security failure:', e.detail); console.error('VNC security failure:', e.detail);
showNotification('VNC security failure: ' + e.detail.reason, 'danger'); // Show password modal again for retry
const passwordModal = new bootstrap.Modal(document.getElementById('passwordModal'));
document.getElementById('passwordModalLabel').textContent = 'VNC Authentication Failed';
document.querySelector('#passwordModal .modal-body p').textContent = 'The password you entered is incorrect. Please try again:';
document.getElementById('vncPassword').value = ''; // Clear previous password
passwordModal.show();
// Handle password resubmission
const submitPassword = () => {
const password = document.getElementById('vncPassword').value;
if (password) {
rfb.sendCredentials({ password: password });
passwordModal.hide();
document.getElementById('vncPassword').value = ''; // Clear password field
}
};
document.getElementById('submitPasswordBtn').onclick = submitPassword;
// Allow Enter key to submit
document.getElementById('vncPassword').onkeydown = (e) => {
if (e.key === 'Enter') {
submitPassword();
}
};
// Handle modal close without password
document.getElementById('passwordModal').addEventListener('hidden.bs.modal', () => {
if (!rfb._rfbCredentials.password) {
// If no password was provided, disconnect
showNotification('VNC connection cancelled - password required', 'warning');
disconnect();
}
});
}); });
rfb.addEventListener('clipboard', (e) => { rfb.addEventListener('clipboard', (e) => {
...@@ -462,9 +495,7 @@ function disconnect() { ...@@ -462,9 +495,7 @@ function disconnect() {
document.getElementById('noVNC_status').style.display = 'block'; document.getElementById('noVNC_status').style.display = 'block';
document.getElementById('noVNC_loading').style.display = 'none'; document.getElementById('noVNC_loading').style.display = 'none';
document.getElementById('cancelConnectBtn').style.display = 'none'; document.getElementById('cancelConnectBtn').style.display = 'none';
setTimeout(() => {
location.reload(); location.reload();
}, 3000);
} }
function cancelConnect() { function cancelConnect() {
......
...@@ -2571,6 +2571,7 @@ static int handle_request(int client_fd, const http_request_t *req) { ...@@ -2571,6 +2571,7 @@ static int handle_request(int client_fd, const http_request_t *req) {
if (strstr(req->path, ".html")) content_type = "text/html"; if (strstr(req->path, ".html")) content_type = "text/html";
else if (strstr(req->path, ".css")) content_type = "text/css"; else if (strstr(req->path, ".css")) content_type = "text/css";
else if (strstr(req->path, ".js")) content_type = "application/javascript"; else if (strstr(req->path, ".js")) content_type = "application/javascript";
else if (strstr(req->path, ".wasm")) content_type = "application/wasm";
else if (strstr(req->path, ".jpg") || strstr(req->path, ".jpeg")) content_type = "image/jpeg"; else if (strstr(req->path, ".jpg") || strstr(req->path, ".jpeg")) content_type = "image/jpeg";
else if (strstr(req->path, ".png")) content_type = "image/png"; else if (strstr(req->path, ".png")) content_type = "image/png";
else if (strstr(req->path, ".ico")) content_type = "image/x-icon"; else if (strstr(req->path, ".ico")) content_type = "image/x-icon";
......
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