guacamole-common-js 1.4.0-c → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -39,6 +39,14 @@ in favor of the new version of the fork which is much easier to maintain thanks
39
39
  #### Version numbers
40
40
  I intend to keep the npm version numbers identical to the guacamole version that I publish. This doesn't always work 100% in case something is missing or at fault, so I will need to release a patch. These patch versions still keep the same version number, but add a letter designating the patch (e.g. `1.0.0-b`). In case the guacamole upstream ever releases any patches with a similar version number, I can't guarantee that the patch letter of the original Guacamole sources and the release of this fork match up for that specific version.
41
41
 
42
+ #### Fork origin
43
+ Apparently the original repository `[glyptodon/guacamole-client](https://github.com/glyptodon/guacamole-client)` is no longer maintained and the actual guacamole client is now maintained at `[apache/guacamole-client](https://github.com/apache/guacamole-client)`. Unfortunately there is no way to rewrite the fork origin on GitHub, so this repository will show the wrong origin. In order to update from upstream, you may do the following:
44
+
45
+ ```
46
+ $ git remote add upstream git@github.com:apache/guacamole-client.git
47
+ $ git pull upstream master --rebase
48
+ ```
49
+
42
50
  ## Documentation
43
51
  Distribution-specific packages are available from the files section of the main
44
52
  project page:
@@ -1808,14 +1808,7 @@ Guacamole.Client = function(tunnel) {
1808
1808
 
1809
1809
  var guac_client = this;
1810
1810
 
1811
- var STATE_IDLE = 0;
1812
- var STATE_CONNECTING = 1;
1813
- var STATE_WAITING = 2;
1814
- var STATE_CONNECTED = 3;
1815
- var STATE_DISCONNECTING = 4;
1816
- var STATE_DISCONNECTED = 5;
1817
-
1818
- var currentState = STATE_IDLE;
1811
+ var currentState = Guacamole.Client.State.IDLE;
1819
1812
 
1820
1813
  var currentTimestamp = 0;
1821
1814
 
@@ -1937,8 +1930,8 @@ Guacamole.Client = function(tunnel) {
1937
1930
  }
1938
1931
 
1939
1932
  function isConnected() {
1940
- return currentState == STATE_CONNECTED
1941
- || currentState == STATE_WAITING;
1933
+ return currentState == Guacamole.Client.State.CONNECTED
1934
+ || currentState == Guacamole.Client.State.WAITING;
1942
1935
  }
1943
1936
 
1944
1937
  /**
@@ -2492,6 +2485,64 @@ Guacamole.Client = function(tunnel) {
2492
2485
  * A status object which describes the error.
2493
2486
  */
2494
2487
  this.onerror = null;
2488
+
2489
+ /**
2490
+ * Fired when an arbitrary message is received from the tunnel that should
2491
+ * be processed by the client. By default, additional message-specific
2492
+ * events such as "onjoin" and "onleave" will fire for the received message
2493
+ * after this event has been processed. An event handler for "onmsg" need
2494
+ * not be supplied if "onjoin" and/or "onleave" will be used.
2495
+ *
2496
+ * @event
2497
+ * @param {!number} msgcode
2498
+ * A status code sent by the remote server that indicates the nature of
2499
+ * the message that is being sent to the client.
2500
+ *
2501
+ * @param {string[]} args
2502
+ * An array of arguments to be processed with the message sent to the
2503
+ * client.
2504
+ *
2505
+ * @return {boolean}
2506
+ * true if message-specific events such as "onjoin" and
2507
+ * "onleave" should be fired for this message, false otherwise. If
2508
+ * no value is returned, message-specific events will be allowed to
2509
+ * fire.
2510
+ */
2511
+ this.onmsg = null;
2512
+
2513
+ /**
2514
+ * Fired when a user joins a shared connection.
2515
+ *
2516
+ * @event
2517
+ * @param {!string} userID
2518
+ * A unique value representing this specific user's connection to the
2519
+ * shared connection. This value is generated by the server and is
2520
+ * guaranteed to be unique relative to other users of the connection.
2521
+ *
2522
+ * @param {!string} name
2523
+ * A human-readable name representing the user that joined, such as
2524
+ * their username. This value is provided by the web application during
2525
+ * the connection handshake and is not necessarily unique relative to
2526
+ * other users of the connection.
2527
+ */
2528
+ this.onjoin = null;
2529
+
2530
+ /**
2531
+ * Fired when a user leaves a shared connection.
2532
+ *
2533
+ * @event
2534
+ * @param {!string} userID
2535
+ * A unique value representing this specific user's connection to the
2536
+ * shared connection. This value is generated by the server and is
2537
+ * guaranteed to be unique relative to other users of the connection.
2538
+ *
2539
+ * @param {!string} name
2540
+ * A human-readable name representing the user that left, such as their
2541
+ * username. This value is provided by the web application during the
2542
+ * connection handshake and is not necessarily unique relative to other
2543
+ * users of the connection.
2544
+ */
2545
+ this.onleave = null;
2495
2546
 
2496
2547
  /**
2497
2548
  * Fired when a audio stream is created. The stream provided to this event
@@ -3210,6 +3261,44 @@ Guacamole.Client = function(tunnel) {
3210
3261
  }
3211
3262
 
3212
3263
  },
3264
+
3265
+ "msg" : function(parameters) {
3266
+
3267
+ var userID;
3268
+ var username;
3269
+
3270
+ // Fire general message handling event first
3271
+ var allowDefault = true;
3272
+ var msgid = parseInt(parameters[0]);
3273
+ if (guac_client.onmsg) {
3274
+ allowDefault = guac_client.onmsg(msgid, parameters.slice(1));
3275
+ if (allowDefault === undefined)
3276
+ allowDefault = true;
3277
+ }
3278
+
3279
+ // Fire message-specific convenience events if not prevented by the
3280
+ // "onmsg" handler
3281
+ if (allowDefault) {
3282
+ switch (msgid) {
3283
+
3284
+ case Guacamole.Client.Message.USER_JOINED:
3285
+ userID = parameters[1];
3286
+ username = parameters[2];
3287
+ if (guac_client.onjoin)
3288
+ guac_client.onjoin(userID, username);
3289
+ break;
3290
+
3291
+ case Guacamole.Client.Message.USER_LEFT:
3292
+ userID = parameters[1];
3293
+ username = parameters[2];
3294
+ if (guac_client.onleave)
3295
+ guac_client.onleave(userID, username);
3296
+ break;
3297
+
3298
+ }
3299
+ }
3300
+
3301
+ },
3213
3302
 
3214
3303
  "name": function(parameters) {
3215
3304
  if (guac_client.onname) guac_client.onname(parameters[0]);
@@ -3362,8 +3451,8 @@ Guacamole.Client = function(tunnel) {
3362
3451
  }, timestamp, frames);
3363
3452
 
3364
3453
  // If received first update, no longer waiting.
3365
- if (currentState === STATE_WAITING)
3366
- setState(STATE_CONNECTED);
3454
+ if (currentState === Guacamole.Client.State.WAITING)
3455
+ setState(Guacamole.Client.State.CONNECTED);
3367
3456
 
3368
3457
  // Call sync handler if defined
3369
3458
  if (guac_client.onsync)
@@ -3519,10 +3608,10 @@ Guacamole.Client = function(tunnel) {
3519
3608
  this.disconnect = function() {
3520
3609
 
3521
3610
  // Only attempt disconnection not disconnected.
3522
- if (currentState != STATE_DISCONNECTED
3523
- && currentState != STATE_DISCONNECTING) {
3611
+ if (currentState != Guacamole.Client.State.DISCONNECTED
3612
+ && currentState != Guacamole.Client.State.DISCONNECTING) {
3524
3613
 
3525
- setState(STATE_DISCONNECTING);
3614
+ setState(Guacamole.Client.State.DISCONNECTING);
3526
3615
 
3527
3616
  // Stop sending keep-alive messages
3528
3617
  stopKeepAlive();
@@ -3530,7 +3619,7 @@ Guacamole.Client = function(tunnel) {
3530
3619
  // Send disconnect message and disconnect
3531
3620
  tunnel.sendMessage("disconnect");
3532
3621
  tunnel.disconnect();
3533
- setState(STATE_DISCONNECTED);
3622
+ setState(Guacamole.Client.State.DISCONNECTED);
3534
3623
 
3535
3624
  }
3536
3625
 
@@ -3549,13 +3638,13 @@ Guacamole.Client = function(tunnel) {
3549
3638
  */
3550
3639
  this.connect = function(data) {
3551
3640
 
3552
- setState(STATE_CONNECTING);
3641
+ setState(Guacamole.Client.State.CONNECTING);
3553
3642
 
3554
3643
  try {
3555
3644
  tunnel.connect(data);
3556
3645
  }
3557
3646
  catch (status) {
3558
- setState(STATE_IDLE);
3647
+ setState(Guacamole.Client.State.IDLE);
3559
3648
  throw status;
3560
3649
  }
3561
3650
 
@@ -3563,11 +3652,63 @@ Guacamole.Client = function(tunnel) {
3563
3652
  // still here, even if not active
3564
3653
  scheduleKeepAlive();
3565
3654
 
3566
- setState(STATE_WAITING);
3655
+ setState(Guacamole.Client.State.WAITING);
3567
3656
  };
3568
3657
 
3569
3658
  };
3570
3659
 
3660
+ /**
3661
+ * All possible Guacamole Client states.
3662
+ *
3663
+ * @type {!Object.<string, number>}
3664
+ */
3665
+ Guacamole.Client.State = {
3666
+
3667
+ /**
3668
+ * The client is idle, with no active connection.
3669
+ *
3670
+ * @type number
3671
+ */
3672
+ "IDLE" : 0,
3673
+
3674
+ /**
3675
+ * The client is in the process of establishing a connection.
3676
+ *
3677
+ * @type {!number}
3678
+ */
3679
+ "CONNECTING" : 1,
3680
+
3681
+ /**
3682
+ * The client is waiting on further information or a remote server to
3683
+ * establish the connection.
3684
+ *
3685
+ * @type {!number}
3686
+ */
3687
+ "WAITING" : 2,
3688
+
3689
+ /**
3690
+ * The client is actively connected to a remote server.
3691
+ *
3692
+ * @type {!number}
3693
+ */
3694
+ "CONNECTED" : 3,
3695
+
3696
+ /**
3697
+ * The client is in the process of disconnecting from the remote server.
3698
+ *
3699
+ * @type {!number}
3700
+ */
3701
+ "DISCONNECTING" : 4,
3702
+
3703
+ /**
3704
+ * The client has completed the connection and is no longer connected.
3705
+ *
3706
+ * @type {!number}
3707
+ */
3708
+ "DISCONNECTED" : 5
3709
+
3710
+ };
3711
+
3571
3712
  /**
3572
3713
  * Map of all Guacamole binary raster operations to transfer functions.
3573
3714
  *
@@ -3684,6 +3825,34 @@ Guacamole.Client.DefaultTransferFunction = {
3684
3825
  dst.blue = 0xFF & ( src.blue | ~dst.blue);
3685
3826
  }
3686
3827
 
3828
+ };
3829
+
3830
+ /**
3831
+ * A list of possible messages that can be sent by the server for processing
3832
+ * by the client.
3833
+ *
3834
+ * @type {!Object.<string, number>}
3835
+ */
3836
+ Guacamole.Client.Message = {
3837
+
3838
+ /**
3839
+ * A client message that indicates that a user has joined an existing
3840
+ * connection. This message expects a single additional argument - the
3841
+ * name of the user who has joined the connection.
3842
+ *
3843
+ * @type {!number}
3844
+ */
3845
+ "USER_JOINED": 0x0001,
3846
+
3847
+ /**
3848
+ * A client message that indicates that a user has left an existing
3849
+ * connection. This message expects a single additional argument - the
3850
+ * name of the user who has left the connection.
3851
+ *
3852
+ * @type {!number}
3853
+ */
3854
+ "USER_LEFT": 0x0002
3855
+
3687
3856
  };
3688
3857
  /*
3689
3858
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -15978,7 +16147,7 @@ var Guacamole = Guacamole || {};
15978
16147
  *
15979
16148
  * @type {!string}
15980
16149
  */
15981
- Guacamole.API_VERSION = "1.4.0";
16150
+ Guacamole.API_VERSION = "1.5.0";
15982
16151
  /*
15983
16152
  * Licensed to the Apache Software Foundation (ASF) under one
15984
16153
  * or more contributor license agreements. See the NOTICE file