git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: 1ffd915b15f2f2a528bc6e5329be0be2c9cab33b

Files: 1ffd915b15f2f2a528bc6e5329be0be2c9cab33b / message.js

926 bytesRaw
1const EventEmitter = require('events')
2
3/**
4 * This implements Messages for Primea
5 * @module primea-message
6 */
7module.exports = class Message extends EventEmitter {
8 /**
9 * @param {Object} opts
10 * @param {ArrayBuffer} opts.data - the payload of the message
11 * @param {Array<Object>} opts.caps - an array of capabilities to send in the message
12 */
13 constructor (opts) {
14 super()
15 const defaults = this.constructor.defaults
16 this._opts = Object.assign(defaults, opts)
17 Object.keys(this._opts).forEach(key => {
18 Object.defineProperty(this, key, {
19 get: function () {
20 return this._opts[key]
21 },
22 set: function (y) {
23 this._opts[key] = y
24 }
25 })
26 })
27 }
28
29 static get defaults () {
30 return {
31 ticks: 0,
32 funcRef: null,
33 funcArguments: [],
34 funcParameters: [],
35 _fromId: Buffer.alloc(20),
36 _fromTicks: 0
37 }
38 }
39}
40

Built with git-ssb-web