mike-jumper commented on code in PR #358:
URL: https://github.com/apache/guacamole-server/pull/358#discussion_r1032698429
##########
src/libguac/client.c:
##########
@@ -701,6 +739,122 @@ 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;
+
+ if (user == NULL)
+ return (void*) ((intptr_t) -1);
+
+ char* logOwner = "owner";
+ if (user->info.name != NULL)
+ logOwner = (char *) user->info.name;
+
+ char* logJoiner = "anonymous";
+ char* sendJoiner = "";
+ if (joiner->info.name != NULL) {
+ logJoiner = (char *) joiner->info.name;
+ sendJoiner = (char *) joiner->info.name;
+ }
+
+ guac_user_log(user, GUAC_LOG_DEBUG, "Notifying owner \"%s\" of \"%s\"
joining.", logOwner, logJoiner);
+
+ /* Send user joined notification to owner. */
+ const char* args[] = { (const char*)joiner->user_id, (const
char*)sendJoiner, NULL };
+ return (void*) ((intptr_t) guac_protocol_send_msg(user->socket,
GUAC_MESSAGE_USER_JOINED, args));
+
+}
+
+int guac_client_owner_notify_join(guac_client* client, guac_user* joiner) {
+
+ /* Don't send msg instruction if client does not support it. */
+ if (!guac_client_owner_supports_msg(client)) {
+ guac_client_log(client, GUAC_LOG_DEBUG,
+ "Client does not support the \"msg\" instruction and "
+ "will not be notified of the user joining the
connection.");
+ return -1;
+ }
+
+ return (int) ((intptr_t) guac_client_for_owner(client,
guac_client_owner_notify_join_callback, joiner));
+
+}
+
+/**
+ * A callback function that is invokved by guac_client_owner_notify_leave() to
+ * notify the owner of a connection that another user has left 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 leaving 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_leave_callback(guac_user* user, void*
data) {
+
+ const guac_user* quitter = (const guac_user *) data;
+
+ if (user == NULL)
+ return (void*) ((intptr_t) -1);
+
+ char* logOwner = "owner";
+ if (user->info.name != NULL)
+ logOwner = (char *) user->info.name;
+
+ char* logQuitter = "anonymous";
+ char* sendQuitter = "";
+ if (quitter->info.name != NULL) {
+ logQuitter = (char *) quitter->info.name;
+ sendQuitter = (char *) quitter->info.name;
+ }
Review Comment:
`same_here`
##########
src/libguac/client.c:
##########
@@ -701,6 +739,122 @@ 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;
+
+ if (user == NULL)
+ return (void*) ((intptr_t) -1);
+
+ char* logOwner = "owner";
+ if (user->info.name != NULL)
+ logOwner = (char *) user->info.name;
+
+ char* logJoiner = "anonymous";
+ char* sendJoiner = "";
+ if (joiner->info.name != NULL) {
+ logJoiner = (char *) joiner->info.name;
+ sendJoiner = (char *) joiner->info.name;
+ }
Review Comment:
These should be `lowercase_with_underscores` rather than `headlessCamelCase`.
--
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]