• Home
  • Raw
  • Download

Lines Matching full:this

8  * via websockify. This is accomplished by base64 encoding the data
53 this._websocket = null; // WebSocket object
54 this._rQ = []; // Receive queue
55 this._rQi = 0; // Receive queue index
56 this._rQmax = 10000; // Max receive queue size before compacting
57 this._sQ = []; // Send queue
59 this._mode = 'base64'; // Current WebSocket mode: 'binary', 'base64'
60 this.maxBufferedAmount = 200;
62 this._eventHandlers = {
75 return this._sQ;
79 return this._rQ;
83 return this._rQi;
87 this._rQi = val;
92 return this._rQ.length - this._rQi;
96 return this._rQ[this._rQi];
100 return this._rQ[this._rQi++];
104 this._rQi++;
108 this._rQi += num;
112 if (this._rQi === 0) {
113 this._rQ.unshift(num);
115 this._rQi--;
116 this._rQ[this._rQi] = num;
121 return (this._rQ[this._rQi++] << 8) +
122 this._rQ[this._rQi++];
126 return (this._rQ[this._rQi++] << 24) +
127 (this._rQ[this._rQi++] << 16) +
128 (this._rQ[this._rQi++] << 8) +
129 this._rQ[this._rQi++];
133 if (typeof(len) === 'undefined') { len = this.rQlen(); }
134 var arr = this._rQ.slice(this._rQi, this._rQi + len);
135 this._rQi += len;
140 if (typeof(len) === 'undefined') { len = this.rQlen(); }
141 this._rQi += len;
142 return this._rQ.slice(this._rQi - len, this._rQi);
147 return this._rQ.slice(this._rQi + start, this._rQi + end);
149 return this._rQ.slice(this._rQi + start);
157 var rQlen = this._rQ.length - this._rQi; // Skip rQlen() function call
160 if (this._rQi < goback) {
163 this._rQi -= goback;
173 if (this._websocket.bufferedAmount !== 0) {
174 Util.Debug("bufferedAmount: " + this._websocket.bufferedAmount);
177 if (this._websocket.bufferedAmount < this.maxBufferedAmount) {
178 if (this._sQ.length > 0) {
179 this._websocket.send(this._encode_message());
180 this._sQ = [];
186 this._websocket.bufferedAmount);
192 this._sQ = this._sQ.concat(arr);
193 return this.flush();
197 this.send(str.split('').map(function (chr) {
204 this._eventHandlers[evt] = handler;
208 this._rQ = [];
209 this._rQi = 0;
210 this._sQ = [];
211 this._websocket = null;
273 protocols = this.init(protocols, ws_schema);
275 this._websocket = new WebSocket(uri, protocols);
278 this._websocket.binaryType = 'arraybuffer';
281 this._websocket.onmessage = this._recv_message.bind(this);
282 this._websocket.onopen = (function () {
284 if (this._websocket.protocol) {
285 this._mode = this._websocket.protocol;
286 Util.Info("Server choose sub-protocol: " + this._websocket.protocol);
288 this._mode = 'base64';
289 Util.Error('Server select no sub-protocol!: ' + this._websocket.protocol);
291 this._eventHandlers.open();
293 }).bind(this);
294 this._websocket.onclose = (function (e) {
296 this._eventHandlers.close(e);
298 }).bind(this);
299 this._websocket.onerror = (function (e) {
301 this._eventHandlers.error(e);
303 }).bind(this);
307 if (this._websocket) {
308 if ((this._websocket.readyState === WebSocket.OPEN) ||
309 (this._websocket.readyState === WebSocket.CONNECTING)) {
311 this._websocket.close();
314 this._websocket.onmessage = function (e) { return; };
320 if (this._mode === 'binary') {
322 return (new Uint8Array(this._sQ)).buffer;
325 return Base64.encode(this._sQ);
330 if (this._mode === 'binary') {
334 this._rQ.push(u8[i]);
338 this._rQ = this._rQ.concat(Base64.decode(data, 0));
344 this._decode_message(e.data);
345 if (this.rQlen() > 0) {
346 this._eventHandlers.message();
348 if (this._rQ.length > this._rQmax) {
349 this._rQ = this._rQ.slice(this._rQi);
350 this._rQi = 0;
377 this._eventHandlers.error(exc.name + ": " + exc.message);
379 this._eventHandlers.error(exc);