aleitner commented on code in PR #610:
URL: https://github.com/apache/guacamole-server/pull/610#discussion_r2677532163


##########
src/libguac/guacamole/protocol.h:
##########
@@ -1155,5 +1155,42 @@ guac_protocol_version 
guac_protocol_string_to_version(const char* version_string
  */
 const char* guac_protocol_version_to_string(guac_protocol_version version);
 
-#endif
+/**
+ * Sends a usbdisconnect instruction over the given guac_socket connection,
+ * requesting that the client disconnect the specified USB device.
+ *
+ * @param socket
+ *     The guac_socket connection to use.
+ *
+ * @param device_id
+ *     The unique identifier of the USB device that should be disconnected.
+ *
+ * @return
+ *     Zero on success, non-zero on error.
+ */
+int guac_protocol_send_usbdisconnect(guac_socket* socket, 
+        const char* device_id);
+
+/**
+ * Sends a usbdata instruction over the given guac_socket connection,
+ * sending USB data to a specific endpoint on a client-side USB device.
+ *
+ * @param socket
+ *     The guac_socket connection to use.
+ *
+ * @param device_id
+ *     The unique identifier of the USB device.
+ *
+ * @param endpoint_number
+ *     The endpoint number to send data to.
+ *
+ * @param data
+ *     The base64-encoded data to send to the USB device.
+ *
+ * @return
+ *     Zero on success, non-zero on error.
+ */
+int guac_protocol_send_usbdata(guac_socket* socket, const char* device_id,
+        int endpoint_number, const char* data);

Review Comment:
   I should clarify the architecture here! The asymmetry you noticed is 
actually intended by design. USB devices are physically connected to the client 
and redirected TO the server, not the other way around. The flow works like 
this:
   
   1. Client detects USB device and sends `usbconnect` instruction to server
   2. Server's `usbconnect_handler` decides whether to accept the device
   3. Once accepted, server can send `usbdata` instructions to communicate with 
the device
   4. Either side can terminate the redirection with `usbdisconnect`
   
   Since the server never initiates USB device connections on the client side 
(it can only respond to client-offered devices), there's no need for a 
`guac_protocol_send_usbconnect` function. THe disconnect function exists so the 
server can request the client to stop redirecting a device that was previously 
connected.
   
   Let me know if I am misunderstanding what you are proposing!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to