No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

message.js 737B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. var Buffer = require('safe-buffer').Buffer;
  3. var Message = function() {
  4. this.rsv1 = false;
  5. this.rsv2 = false;
  6. this.rsv3 = false;
  7. this.opcode = null;
  8. this.length = 0;
  9. this._chunks = [];
  10. };
  11. var instance = {
  12. read: function() {
  13. return this.data = this.data || Buffer.concat(this._chunks, this.length);
  14. },
  15. pushFrame: function(frame) {
  16. this.rsv1 = this.rsv1 || frame.rsv1;
  17. this.rsv2 = this.rsv2 || frame.rsv2;
  18. this.rsv3 = this.rsv3 || frame.rsv3;
  19. if (this.opcode === null) this.opcode = frame.opcode;
  20. this._chunks.push(frame.payload);
  21. this.length += frame.length;
  22. }
  23. };
  24. for (var key in instance)
  25. Message.prototype[key] = instance[key];
  26. module.exports = Message;