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 | |
---|
20 | var Guacamole = Guacamole || {}; |
---|
21 | |
---|
22 | /** |
---|
23 | * Abstract stream which can receive data. |
---|
24 | * |
---|
25 | * @constructor |
---|
26 | * @param {Guacamole.Client} client The client owning this stream. |
---|
27 | * @param {Number} index The index of this stream. |
---|
28 | */ |
---|
29 | Guacamole.OutputStream = function(client, index) { |
---|
30 | |
---|
31 | /** |
---|
32 | * Reference to this stream. |
---|
33 | * @private |
---|
34 | */ |
---|
35 | var guac_stream = this; |
---|
36 | |
---|
37 | /** |
---|
38 | * The index of this stream. |
---|
39 | * @type {Number} |
---|
40 | */ |
---|
41 | this.index = index; |
---|
42 | |
---|
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 The status of the operation. |
---|
49 | */ |
---|
50 | this.onack = null; |
---|
51 | |
---|
52 | /** |
---|
53 | * Writes the given base64-encoded data to this stream as a blob. |
---|
54 | * |
---|
55 | * @param {String} data The base64-encoded data to send. |
---|
56 | */ |
---|
57 | this.sendBlob = function(data) { |
---|
58 | client.sendBlob(guac_stream.index, data); |
---|
59 | }; |
---|
60 | |
---|
61 | /** |
---|
62 | * Closes this stream. |
---|
63 | */ |
---|
64 | this.sendEnd = function() { |
---|
65 | client.endStream(guac_stream.index); |
---|
66 | }; |
---|
67 | |
---|
68 | }; |
---|