git ssb

0+

wanderer🌟 / js-primea-hypervisor



Tree: 72a22f7318aa0ad186ba6c2b134f0d45a091a18d

Files: 72a22f7318aa0ad186ba6c2b134f0d45a091a18d / message.js

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

Built with git-ssb-web