summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Grunt <pgrunt@redhat.com>2015-01-14 17:44:39 +0100
committerJeremy White <jwhite@codeweavers.com>2015-01-15 08:59:55 -0600
commit633f01050b3cde2488f4b05e971d3aaf258357eb (patch)
tree4f590120dc3cb51ef02471046efa619cc5de5ec5
parent1a4a98938a1ff44789e3a81ad115f4dd86cfee15 (diff)
Split agent data message into smaller chunks
Allowed size for SPICE_MSGC_MAIN_AGENT_DATA message is 2048 Bytes, larger messages have to be splitted.
-rw-r--r--enums.js1
-rw-r--r--main.js16
2 files changed, 14 insertions, 3 deletions
diff --git a/enums.js b/enums.js
index fcf27e6..4b678df 100644
--- a/enums.js
+++ b/enums.js
@@ -312,6 +312,7 @@ var SPICE_CURSOR_TYPE_ALPHA = 0,
var SPICE_VIDEO_CODEC_TYPE_MJPEG = 1;
var VD_AGENT_PROTOCOL = 1;
+var VD_AGENT_MAX_DATA_SIZE = 2048;
var VD_AGENT_MOUSE_STATE = 1,
VD_AGENT_MONITORS_CONFIG = 2,
diff --git a/main.js b/main.js
index 5dc2b72..fce2f41 100644
--- a/main.js
+++ b/main.js
@@ -224,9 +224,19 @@ SpiceMainConn.prototype.send_agent_message_queue = function(message)
SpiceMainConn.prototype.send_agent_message = function(type, message)
{
var agent_data = new SpiceMsgcMainAgentData(type, message);
- var mr = new SpiceMiniData();
- mr.build_msg(SPICE_MSGC_MAIN_AGENT_DATA, agent_data);
- this.send_agent_message_queue(mr);
+ var sb = 0, maxsize = VD_AGENT_MAX_DATA_SIZE - SpiceMiniData.prototype.buffer_size();
+ var data = new ArrayBuffer(agent_data.buffer_size());
+ agent_data.to_buffer(data);
+ while (sb < agent_data.buffer_size())
+ {
+ var eb = Math.min(sb + maxsize, agent_data.buffer_size());
+ var mr = new SpiceMiniData();
+ mr.type = SPICE_MSGC_MAIN_AGENT_DATA;
+ mr.size = eb - sb;
+ mr.data = data.slice(sb, eb);
+ this.send_agent_message_queue(mr);
+ sb = eb;
+ }
}
SpiceMainConn.prototype.resize_window = function(flags, width, height, depth, x, y)