You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/01/30 19:06:53 UTC

[6/9] guacamole-server git commit: GUACAMOLE-313: Include timestamp with mouse position reporting.

GUACAMOLE-313: Include timestamp with mouse position reporting.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/a74d6a2a
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/a74d6a2a
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/a74d6a2a

Branch: refs/heads/master
Commit: a74d6a2aaf40bcf997086b846c7b5904682852e7
Parents: e2455d6
Author: Michael Jumper <mj...@apache.org>
Authored: Mon Nov 27 20:08:34 2017 -0800
Committer: Michael Jumper <mj...@apache.org>
Committed: Fri Jan 26 16:21:49 2018 -0800

----------------------------------------------------------------------
 src/common/common/cursor.h       |  6 ++++++
 src/common/cursor.c              | 11 +++++++++--
 src/common/recording.c           |  4 +++-
 src/libguac/guacamole/protocol.h |  7 ++++++-
 src/libguac/protocol.c           |  5 ++++-
 5 files changed, 28 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/a74d6a2a/src/common/common/cursor.h
----------------------------------------------------------------------
diff --git a/src/common/common/cursor.h b/src/common/common/cursor.h
index 00bc48e..30316f4 100644
--- a/src/common/common/cursor.h
+++ b/src/common/common/cursor.h
@@ -102,6 +102,12 @@ typedef struct guac_common_cursor {
      */
     int y;
 
+    /**
+     * The server timestamp representing the point in time when the mousr
+     * location was last updated.
+     */
+    guac_timestamp timestamp;
+
 } guac_common_cursor;
 
 /**

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/a74d6a2a/src/common/cursor.c
----------------------------------------------------------------------
diff --git a/src/common/cursor.c b/src/common/cursor.c
index f621b94..7f4fb8f 100644
--- a/src/common/cursor.c
+++ b/src/common/cursor.c
@@ -28,6 +28,7 @@
 #include <guacamole/client.h>
 #include <guacamole/protocol.h>
 #include <guacamole/socket.h>
+#include <guacamole/timestamp.h>
 #include <guacamole/user.h>
 
 #include <limits.h>
@@ -67,6 +68,7 @@ guac_common_cursor* guac_common_cursor_alloc(guac_client* client) {
 
     /* No user has moved the mouse yet */
     cursor->user = NULL;
+    cursor->timestamp = guac_timestamp_current();
 
     /* Start cursor in upper-left */
     cursor->x = 0;
@@ -101,7 +103,8 @@ void guac_common_cursor_dup(guac_common_cursor* cursor, guac_user* user,
         guac_socket* socket) {
 
     /* Synchronize location */
-    guac_protocol_send_mouse(socket, cursor->x, cursor->y);
+    guac_protocol_send_mouse(socket, cursor->x, cursor->y,
+            cursor->timestamp);
 
     /* Synchronize cursor image */
     if (cursor->surface != NULL) {
@@ -138,7 +141,8 @@ static void* guac_common_cursor_broadcast_position(guac_user* user,
 
     /* Send cursor position only if the user is not moving the cursor */
     if (user != cursor->user) {
-        guac_protocol_send_mouse(user->socket, cursor->x, cursor->y);
+        guac_protocol_send_mouse(user->socket, cursor->x, cursor->y,
+                cursor->timestamp);
         guac_socket_flush(user->socket);
     }
 
@@ -156,6 +160,9 @@ void guac_common_cursor_move(guac_common_cursor* cursor, guac_user* user,
     cursor->x = x;
     cursor->y = y;
 
+    /* Store time at which cursor position was updated */
+    cursor->timestamp = guac_timestamp_current();
+
     /* Notify all other users of change in cursor position */
     guac_client_foreach_user(cursor->client,
             guac_common_cursor_broadcast_position, cursor);

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/a74d6a2a/src/common/recording.c
----------------------------------------------------------------------
diff --git a/src/common/recording.c b/src/common/recording.c
index 4f334d5..e7270d6 100644
--- a/src/common/recording.c
+++ b/src/common/recording.c
@@ -22,6 +22,7 @@
 #include <guacamole/client.h>
 #include <guacamole/protocol.h>
 #include <guacamole/socket.h>
+#include <guacamole/timestamp.h>
 
 #ifdef __MINGW32__
 #include <direct.h>
@@ -182,7 +183,8 @@ void guac_common_recording_report_mouse(guac_common_recording* recording,
         int x, int y) {
 
     /* Report mouse location */
-    guac_protocol_send_mouse(recording->socket, x, y);
+    guac_protocol_send_mouse(recording->socket, x, y,
+            guac_timestamp_current());
 
 }
 

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/a74d6a2a/src/libguac/guacamole/protocol.h
----------------------------------------------------------------------
diff --git a/src/libguac/guacamole/protocol.h b/src/libguac/guacamole/protocol.h
index 88a0a18..89ad6b2 100644
--- a/src/libguac/guacamole/protocol.h
+++ b/src/libguac/guacamole/protocol.h
@@ -159,10 +159,15 @@ int vguac_protocol_send_log(guac_socket* socket, const char* format,
  * @param y
  *     The Y coordinate of the current mouse position.
  *
+ * @param timestamp
+ *     The server timestamp (in milliseconds) at the point in time this mouse
+ *     position was acknowledged.
+ *
  * @return
  *     Zero on success, non-zero on error.
  */
-int guac_protocol_send_mouse(guac_socket* socket, int x, int y);
+int guac_protocol_send_mouse(guac_socket* socket, int x, int y,
+        guac_timestamp timestamp);
 
 /**
  * Sends a nest instruction over the given guac_socket connection.

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/a74d6a2a/src/libguac/protocol.c
----------------------------------------------------------------------
diff --git a/src/libguac/protocol.c b/src/libguac/protocol.c
index 8da1824..5e47b8c 100644
--- a/src/libguac/protocol.c
+++ b/src/libguac/protocol.c
@@ -684,7 +684,8 @@ int guac_protocol_send_lstroke(guac_socket* socket,
 
 }
 
-int guac_protocol_send_mouse(guac_socket* socket, int x, int y) {
+int guac_protocol_send_mouse(guac_socket* socket, int x, int y,
+        guac_timestamp timestamp) {
 
     int ret_val;
 
@@ -694,6 +695,8 @@ int guac_protocol_send_mouse(guac_socket* socket, int x, int y) {
         || __guac_socket_write_length_int(socket, x)
         || guac_socket_write_string(socket, ",")
         || __guac_socket_write_length_int(socket, y)
+        || guac_socket_write_string(socket, ",")
+        || __guac_socket_write_length_int(socket, timestamp)
         || guac_socket_write_string(socket, ";");
 
     guac_socket_instruction_end(socket);