[PATCH spice-html5 1/4] Handle agent tokens

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 main.js     | 20 ++++++++++++++++++--
 spicemsg.js | 15 +++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/main.js b/main.js
index e487551..d9c9f75 100644
--- a/main.js
+++ b/main.js
@@ -87,6 +87,8 @@ SpiceMainConn.prototype.process_channel_message = function(msg)
         if (this.main_init.agent_connected)
             this.connect_agent();
 
+        this.agent_tokens = this.main_init.agent_tokens;
+
         var attach = new SpiceMiniData;
         attach.type = SPICE_MSGC_MAIN_ATTACH_CHANNELS;
         attach.size = attach.buffer_size();
@@ -141,13 +143,27 @@ SpiceMainConn.prototype.process_channel_message = function(msg)
         return true;
     }
 
-    if (msg.type == SPICE_MSG_MAIN_AGENT_CONNECTED ||
-        msg.type == SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS)
+    if (msg.type == SPICE_MSG_MAIN_AGENT_CONNECTED)
+    {
+        this.connect_agent();
+        return true;
+    }
+
+    if (msg.type == SPICE_MSG_MAIN_AGENT_CONNECTED_TOKENS)
     {
+        var connected_tokens = new SpiceMsgMainAgentTokens(msg.data);
+        this.agent_tokens = connected_tokens.num_tokens;
         this.connect_agent();
         return true;
     }
 
+    if (msg.type == SPICE_MSG_MAIN_AGENT_TOKEN)
+    {
+        var tokens = new SpiceMsgMainAgentTokens(msg.data);
+        this.agent_tokens += tokens.num_tokens;
+        return true;
+    }
+
     if (msg.type == SPICE_MSG_MAIN_AGENT_DISCONNECTED)
     {
         this.agent_connected = false;
diff --git a/spicemsg.js b/spicemsg.js
index c64f5a3..0983ae7 100644
--- a/spicemsg.js
+++ b/spicemsg.js
@@ -348,6 +348,21 @@ SpiceMsgMainMouseMode.prototype =
     },
 }
 
+function SpiceMsgMainAgentTokens(a, at)
+{
+    this.from_buffer(a, at);
+}
+
+SpiceMsgMainAgentTokens.prototype =
+{
+    from_buffer: function(a, at)
+    {
+        at = at || 0;
+        var dv = new SpiceDataView(a);
+        this.num_tokens = dv.getUint32(at, true); at += 4;
+    },
+}
+
 function SpiceMsgSetAck(a, at)
 {
     this.from_buffer(a, at);
-- 
1.9.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]