Source: main/webapp/modules/OutputStream.js

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. var Guacamole = Guacamole || {};
  20. /**
  21. * Abstract stream which can receive data.
  22. *
  23. * @constructor
  24. * @param {!Guacamole.Client} client
  25. * The client owning this stream.
  26. *
  27. * @param {!number} index
  28. * The index of this stream.
  29. */
  30. Guacamole.OutputStream = function(client, index) {
  31. /**
  32. * Reference to this stream.
  33. *
  34. * @private
  35. * @type {!Guacamole.OutputStream}
  36. */
  37. var guac_stream = this;
  38. /**
  39. * The index of this stream.
  40. * @type {!number}
  41. */
  42. this.index = index;
  43. /**
  44. * Fired whenever an acknowledgement is received from the server, indicating
  45. * that a stream operation has completed, or an error has occurred.
  46. *
  47. * @event
  48. * @param {!Guacamole.Status} status
  49. * The status of the operation.
  50. */
  51. this.onack = null;
  52. /**
  53. * Writes the given base64-encoded data to this stream as a blob.
  54. *
  55. * @param {!string} data
  56. * The base64-encoded data to send.
  57. */
  58. this.sendBlob = function(data) {
  59. client.sendBlob(guac_stream.index, data);
  60. };
  61. /**
  62. * Closes this stream.
  63. */
  64. this.sendEnd = function() {
  65. client.endStream(guac_stream.index);
  66. };
  67. };