Source: 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 The client owning this stream.
  25. * @param {Number} index The index of this stream.
  26. */
  27. Guacamole.OutputStream = function(client, index) {
  28. /**
  29. * Reference to this stream.
  30. * @private
  31. */
  32. var guac_stream = this;
  33. /**
  34. * The index of this stream.
  35. * @type {Number}
  36. */
  37. this.index = index;
  38. /**
  39. * Fired whenever an acknowledgement is received from the server, indicating
  40. * that a stream operation has completed, or an error has occurred.
  41. *
  42. * @event
  43. * @param {Guacamole.Status} status The status of the operation.
  44. */
  45. this.onack = null;
  46. /**
  47. * Writes the given base64-encoded data to this stream as a blob.
  48. *
  49. * @param {String} data The base64-encoded data to send.
  50. */
  51. this.sendBlob = function(data) {
  52. client.sendBlob(guac_stream.index, data);
  53. };
  54. /**
  55. * Closes this stream.
  56. */
  57. this.sendEnd = function() {
  58. client.endStream(guac_stream.index);
  59. };
  60. };