diff options
author | Pavel Grunt <pgrunt@redhat.com> | 2015-01-15 09:01:04 +0100 |
---|---|---|
committer | Jeremy White <jwhite@codeweavers.com> | 2015-01-15 08:58:30 -0600 |
commit | 21e5c282ba288a5798a864bd7ad1205d3bfd7673 (patch) | |
tree | f4531206078a6ec9888144264c49e242f2687ac6 | |
parent | b926f062f35e298f65828d9835f5b35895ec3729 (diff) |
Handle agent tokens
-rw-r--r-- | main.js | 19 | ||||
-rw-r--r-- | spicemsg.js | 15 |
2 files changed, 32 insertions, 2 deletions
@@ -66,6 +66,7 @@ SpiceMainConn.prototype.process_channel_message = function(msg) this.report_success("Connected") this.main_init = new SpiceMsgMainInit(msg.data); this.connection_id = this.main_init.session_id; + this.agent_tokens = this.main_init.agent_tokens; if (DEBUG > 0) { @@ -141,13 +142,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); |