mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-1293: Allow "onmsg" to determine whether "onjoin" and "onleave" fire.
This commit is contained in:
@@ -690,7 +690,10 @@ Guacamole.Client = function(tunnel) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when an arbitrary message is received from the tunnel that should
|
* Fired when an arbitrary message is received from the tunnel that should
|
||||||
* be processed by the client.
|
* be processed by the client. By default, additional message-specific
|
||||||
|
* events such as "onjoin" and "onleave" will fire for the received message
|
||||||
|
* after this event has been processed. An event handler for "onmsg" need
|
||||||
|
* not be supplied if "onjoin" and/or "onleave" will be used.
|
||||||
*
|
*
|
||||||
* @event
|
* @event
|
||||||
* @param {!number} msgcode
|
* @param {!number} msgcode
|
||||||
@@ -700,6 +703,12 @@ Guacamole.Client = function(tunnel) {
|
|||||||
* @param {string[]} args
|
* @param {string[]} args
|
||||||
* An array of arguments to be processed with the message sent to the
|
* An array of arguments to be processed with the message sent to the
|
||||||
* client.
|
* client.
|
||||||
|
*
|
||||||
|
* @return {boolean}
|
||||||
|
* true if message-specific events such as "onjoin" and
|
||||||
|
* "onleave" should be fired for this message, false otherwise. If
|
||||||
|
* no value is returned, message-specific events will be allowed to
|
||||||
|
* fire.
|
||||||
*/
|
*/
|
||||||
this.onmsg = null;
|
this.onmsg = null;
|
||||||
|
|
||||||
@@ -1454,10 +1463,18 @@ Guacamole.Client = function(tunnel) {
|
|||||||
var userID;
|
var userID;
|
||||||
var username;
|
var username;
|
||||||
|
|
||||||
|
// Fire general message handling event first
|
||||||
|
var allowDefault = true;
|
||||||
var msgid = parseInt(parameters[0]);
|
var msgid = parseInt(parameters[0]);
|
||||||
if (guac_client.onmsg)
|
if (guac_client.onmsg) {
|
||||||
guac_client.onmsg(msgid, parameters.slice(1));
|
allowDefault = guac_client.onmsg(msgid, parameters.slice(1));
|
||||||
|
if (allowDefault === undefined)
|
||||||
|
allowDefault = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire message-specific convenience events if not prevented by the
|
||||||
|
// "onmsg" handler
|
||||||
|
if (allowDefault) {
|
||||||
switch (msgid) {
|
switch (msgid) {
|
||||||
|
|
||||||
case Guacamole.Client.Message.USER_JOINED:
|
case Guacamole.Client.Message.USER_JOINED:
|
||||||
@@ -1475,6 +1492,7 @@ Guacamole.Client = function(tunnel) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user