Add file instruction handler and event, modify parser to not drop length if only partially received.

This commit is contained in:
Michael Jumper
2012-10-26 12:23:18 -07:00
parent 5786dbcf0e
commit 43a823e5c8

View File

@@ -82,7 +82,7 @@ Guacamole.Parser = function() {
this.receive = function(packet) {
// Truncate buffer as necessary
if (start_index > 4096) {
if (start_index > 4096 && element_end >= start_index) {
buffer = buffer.substring(start_index);
@@ -473,6 +473,18 @@ Guacamole.Client = function(tunnel) {
*/
this.onresize = null;
/**
* Fired when a file is received. Note that this will contain the entire
* data of the file.
*
* @event
* @param {String} name A human-readable name describing the file.
* @param {String} mimetype The mimetype of the file received.
* @param {String} data The actual entire contents of the file,
* base64-encoded.
*/
this.onfile = null;
// Layers
function getBufferLayer(index) {
@@ -773,6 +785,15 @@ Guacamole.Client = function(tunnel) {
guac_client.disconnect();
},
"file": function(parameters) {
if (guac_client.onfile)
guac_client.onfile(
parameters[0], // Name
parameters[1], // Mimetype
parameters[2] // Data
);
},
"identity": function(parameters) {
var layer = getLayer(parseInt(parameters[0]));