source: trip-planner-front/node_modules/websocket-driver/lib/websocket/driver/hybi/message.js@ 6fe77af

Last change on this file since 6fe77af was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 737 bytes
Line 
1'use strict';
2
3var Buffer = require('safe-buffer').Buffer;
4
5var Message = function() {
6 this.rsv1 = false;
7 this.rsv2 = false;
8 this.rsv3 = false;
9 this.opcode = null;
10 this.length = 0;
11 this._chunks = [];
12};
13
14var instance = {
15 read: function() {
16 return this.data = this.data || Buffer.concat(this._chunks, this.length);
17 },
18
19 pushFrame: function(frame) {
20 this.rsv1 = this.rsv1 || frame.rsv1;
21 this.rsv2 = this.rsv2 || frame.rsv2;
22 this.rsv3 = this.rsv3 || frame.rsv3;
23
24 if (this.opcode === null) this.opcode = frame.opcode;
25
26 this._chunks.push(frame.payload);
27 this.length += frame.length;
28 }
29};
30
31for (var key in instance)
32 Message.prototype[key] = instance[key];
33
34module.exports = Message;
Note: See TracBrowser for help on using the repository browser.