You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@guacamole.apache.org by GitBox <gi...@apache.org> on 2022/07/25 18:09:31 UTC

[GitHub] [guacamole-server] necouchman commented on a diff in pull request #358: GUACAMOLE-1293: Add support for notifying that a user has joined an existing connection.

necouchman commented on code in PR #358:
URL: https://github.com/apache/guacamole-server/pull/358#discussion_r929163091


##########
src/libguac/client.c:
##########
@@ -701,6 +739,120 @@ int guac_client_owner_supports_required(guac_client* client) {
     
 }
 
+/**
+ * A callback function that is invokved by guac_client_owner_notify_join() to
+ * notify the owner of a connection that another user has joined the
+ * connection, returning zero if the message is sent successfully, or non-zero
+ * if an error occurs.
+ *
+ * @param user
+ *     The user to send the notification to, which will be the owner of the
+ *     connection.
+ *
+ * @param data
+ *     The data provided to the callback, which is the user that is joining the
+ *     connection.
+ *
+ * @return
+ *     Zero if the message is sent successfully to the owner, otherwise
+ *     non-zero, cast as a void*.
+ */
+static void* guac_client_owner_notify_join_callback(guac_user* user, void* data) {
+
+    const guac_user* joiner = (const guac_user *) data;
+    int retval = 0;
+
+    char* owner = "owner";
+    if (user->info.username != NULL)
+        owner = strdup(user->info.username);
+
+    char* joinName = "anonymous";
+    if (joiner->info.username != NULL)
+        joinName = strdup(joiner->info.username);
+
+    guac_user_log(user, GUAC_LOG_DEBUG, "Notifying owner %s of %s joining.", owner, joinName);
+    
+    /* Send required parameters to owner. */
+    if (user != NULL) {
+        const char* args[] = { (const char*)joinName, NULL };
+        retval = guac_protocol_send_msg(user->socket, GUAC_MSG_CLIENT_JOINED, args);
+    }
+
+    else
+        retval = -1;
+
+    free(owner);

Review Comment:
   That's a good question - I'm not sure why I made copies in the first place. Probably should just use the originals...



-- 
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: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org