[Spice-devel] [PATCH spice-html5 1/7] Handle agent tokens
Pavel Grunt
pgrunt at redhat.com
Wed Jan 14 08:44:36 PST 2015
---
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
More information about the Spice-devel
mailing list