Source: InputStream.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. * An input stream abstraction used by the Guacamole client to facilitate
  22. * transfer of files or other binary data.
  23. *
  24. * @constructor
  25. * @param {Guacamole.Client} client The client owning this stream.
  26. * @param {Number} index The index of this stream.
  27. */
  28. Guacamole.InputStream = function(client, index) {
  29. /**
  30. * Reference to this stream.
  31. * @private
  32. */
  33. var guac_stream = this;
  34. /**
  35. * The index of this stream.
  36. * @type {Number}
  37. */
  38. this.index = index;
  39. /**
  40. * Called when a blob of data is received.
  41. *
  42. * @event
  43. * @param {String} data The received base64 data.
  44. */
  45. this.onblob = null;
  46. /**
  47. * Called when this stream is closed.
  48. *
  49. * @event
  50. */
  51. this.onend = null;
  52. /**
  53. * Acknowledges the receipt of a blob.
  54. *
  55. * @param {String} message A human-readable message describing the error
  56. * or status.
  57. * @param {Number} code The error code, if any, or 0 for success.
  58. */
  59. this.sendAck = function(message, code) {
  60. client.sendAck(guac_stream.index, message, code);
  61. };
  62. };