{"_id":"resource-mesh","_rev":"826504","name":"resource-mesh","description":"provides a distributed p2p event emitter mesh","dist-tags":{"latest":"0.5.1"},"maintainers":[{"name":"marak","email":"marak.squires@gmail.com"}],"time":{"modified":"2024-07-09T04:06:45.000Z","created":"2013-06-12T02:03:02.484Z","0.5.1":"2014-11-18T08:57:54.140Z","0.5.0":"2014-06-12T22:39:02.313Z","0.4.2":"2013-07-09T09:55:02.228Z","0.4.0":"2013-06-12T02:03:02.484Z"},"users":{},"versions":{"0.5.1":{"name":"resource-mesh","version":"0.5.1","description":"provides a distributed p2p event emitter mesh","keywords":["mesh","p2p","eventemitter"],"main":"./index.js","scripts":{"test":"tap test"},"dependencies":{"debug":"*","engine.io":"1.4.1","engine.io-client":"1.4.1","eventemitter2":"*","resource":"https://github.com/bigcompany/resource/tarball/master","resource-http":"0.5.x"},"devDependencies":{"tap":"*","colors":"*"},"gitHead":"c31051a799858c4d7a7281ae2a3fd8c6b7d8e20a","_id":"resource-mesh@0.5.1","_shasum":"351eb8b4df1b61511dde14bfe8c1d3294a582407","_from":".","_npmVersion":"2.1.8","_nodeVersion":"0.11.13","_npmUser":{"name":"marak","email":"marak.squires@gmail.com"},"maintainers":[{"name":"marak","email":"marak.squires@gmail.com"}],"dist":{"shasum":"351eb8b4df1b61511dde14bfe8c1d3294a582407","tarball":"http://registry-npm.ywwl.com/resource-mesh/download/resource-mesh-0.5.1.tgz","integrity":"sha512-SlY8eBq9XfhkGAYSBO1w3P3xIzo/yz1yopKmqclDIvmleuzmQ5JJOr9VLIO1NtURhGGVDKjs8z5KcmyCwJZ0uw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD4Foixvcsyloklce6CYyAmzkjJIvDQmByRLjyfCEiojQIgP67osMU4oUNElC42g12FFxevdprSJ8NrqCs3qdiR8Ow="}],"size":80180,"noattachment":false,"key":"/resource-mesh/-/resource-mesh-0.5.1.tgz"},"directories":{},"publish_time":1416301074140,"_cnpm_publish_time":1416301074140},"0.5.0":{"name":"resource-mesh","version":"0.5.0","description":"provides a distributed p2p event emitter mesh","keywords":["mesh","p2p","eventemitter"],"main":"./index.js","dependencies":{"engine.io":"0.3.9","engine.io-client":"0.3.9","eventemitter2":"*","resource":"0.5.x","resource-http":"0.5.x"},"_id":"resource-mesh@0.5.0","_shasum":"dde854a9472d3935f3c3df48f96c3804777c8e6b","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"marak","email":"marak.squires@gmail.com"},"maintainers":[{"name":"marak","email":"marak.squires@gmail.com"}],"dist":{"shasum":"dde854a9472d3935f3c3df48f96c3804777c8e6b","tarball":"http://registry-npm.ywwl.com/resource-mesh/download/resource-mesh-0.5.0.tgz","integrity":"sha512-Jp5VpNpM3j2UR/y/fA8t1CoocMHuoV/7sBxsXygsf4aJi8b6MT0rEq8H1OogCCE18AF2Pr9s/ZwFtVfSYURUag==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIF63lxSBn186ZbhrExRneHnaNwMq+It+D2tIH40LdbHTAiEArrbE2ELjil81nIKzlVmvtHrrWHwXlTtx7HPnXEyxFyA="}],"size":3086,"noattachment":false,"key":"/resource-mesh/-/resource-mesh-0.5.0.tgz"},"directories":{},"publish_time":1402612742313,"_cnpm_publish_time":1402612742313},"0.4.2":{"name":"resource-mesh","version":"0.4.2","description":"provides a distributed p2p event emitter mesh","keywords":["big.vc","resource","resources"],"main":"./index.js","dependencies":{"engine.io":"0.3.9","engine.io-client":"0.3.9","eventemitter2":"*","resource":"0.4.x"},"_id":"resource-mesh@0.4.2","dist":{"shasum":"af1a31ed8e4066344d1dc54a254adebfcadee26e","tarball":"http://registry-npm.ywwl.com/resource-mesh/download/resource-mesh-0.4.2.tgz","integrity":"sha512-g7dbVT5+nC4YvA3HsvRKA3MTJriQyHhz8pBk73+gmEMmwm7zdpJt32L6XmNsYtlSHCZsvGQRmIAA25hb1z3Cuw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG4d4J8hAqp5dzw5J7RszK1oTaxPaLdnO5SFwVuuKlohAiEAswMyVUS08eXYUhf3KvrTpslOtOvOIXXAozo+6tBJqyA="}],"size":3647,"noattachment":false,"key":"/resource-mesh/-/resource-mesh-0.4.2.tgz"},"_from":"/Users/macbookpro/dev/big/resources/mesh","_npmVersion":"1.3.1","_npmUser":{"name":"marak","email":"marak.squires@gmail.com"},"maintainers":[{"name":"marak","email":"marak.squires@gmail.com"}],"directories":{},"publish_time":1373363702228,"_cnpm_publish_time":1373363702228},"0.4.0":{"name":"resource-mesh","version":"0.4.0","description":"provides a distributed p2p event emitter mesh","keywords":["big.vc","resource","resources"],"main":"./index.js","dependencies":{"engine.io":"0.3.9","engine.io-client":"0.3.9","eventemitter2":"*","resource":"0.4.x"},"_id":"resource-mesh@0.4.0","dist":{"shasum":"a9df783cdf3d2f7bf45249ad0f5523da50299b7f","tarball":"http://registry-npm.ywwl.com/resource-mesh/download/resource-mesh-0.4.0.tgz","integrity":"sha512-kqPDtVIj3RYjsYwB6410FfPASVa70i0Aen9qoBeb9c1AmMiX/7LiKDWJRnN4Xv1hx3rzMtp0UwtdI9MaZAv5uA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCIHFZ5mvhQUEGOfzoIzNzu9Gwtw2mfINJ86EssHuUWAgIhALzOESInr7NKrkS7ZOmBvJ6rwusBM3+yE8jj4/p8/C7r"}],"size":3628,"noattachment":false,"key":"/resource-mesh/-/resource-mesh-0.4.0.tgz"},"_from":"./resources/mesh","_npmVersion":"1.2.28","_npmUser":{"name":"marak","email":"marak.squires@gmail.com"},"maintainers":[{"name":"marak","email":"marak.squires@gmail.com"}],"directories":{},"publish_time":1371002582484,"_cnpm_publish_time":1371002582484}},"readme":"# mesh\n\nprovides a distributed event emitter mesh\n\n<img src=\"https://travis-ci.org/bigcompany/mesh.svg?branch=master\"/>\n\n## Features\n\n - Distributed WebSocket event emitter\n - Intelligent event broadcasting among mesh\n - Auto-detection of role as `server` or `client`\n - Powered by `engine.io`\n\n\n## Examples\n\nSee: `./examples` folder\n\n### Basic Mesh\n\nThis example can be run N times in order to create a mesh of event emitting nodes.\n\n`myEvent` is added on each node and also emitted on a timer. \n\nEvery node will then recieve `myEvent` from other nodes.\n\n```js\nmesh.start({ port: 8888 }, function (err) {\n\n  if (err) {\n    throw err;\n  }\n\n  mesh.emitter.on('myEvent', function(data){\n    console.log('mesh ' + this.event + \" - \" + data.pid);\n  });\n\n  setInterval(function(){a\n    mesh.emitter.emit('myEvent', { \"pid\": process.pid });\n  }, 1000);\n\n});\n```\n\nExplicit `server` / `client` can be created using `mesh.listen` and `mesh.connect`.\n\nFor more examples see: `./examples` folder\n\n### Browser Usage\n\nFor browser examples see: `./examples/4_browser/` folder\n\n### Frequent Concerns\n\n**I can't get my nodes to receive custom events!**\n\nDid you bind an event listener using `mesh.emitter.on`? Events **must** be bound in order to be seen on the mesh.\n\n**How can I listen for events using `mesh.emitter.onAny`?**\n\nBy design, `mesh.emitter.onAny` will not receive remote events. This is in order to keep network traffic to a minimum.\n\n**How are events broadcasted among the mesh?**\n\n`mesh` uses a [star topography](http://en.wikipedia.org/wiki/Star_network). The first node is the server and all subsequent nodes are clients.\n\nAll nodes in the mesh are eligible for receiving events from any other node.\n\n<img height=\"250\" width=\"250\" src=\"http://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/StarNetwork.svg/1200px-StarNetwork.svg.png\"/>\n\n - Any events emitted on a `client` will be recieved on the `server`\n   - Provided the `server` has a listener for that event\n - Any events emitted on the `server` will re-broadcast to all `clients`\n   - Provided that `client` has a listener for that event\n - Any events recieved on the `server` will re-broadcast to all `clients`\n   - Excluding the original `client` sender\n   - Provided that `client` has a listener for that event\n\n**How is network traffic kept low if all nodes are in communication?**\n\nAn event map of every node is kept and exchanged on connection with the mesh. Events are then only broadcasted to a node if that event name has been previously registered.\n\n**Can I bind new live events after a connection is made to the mesh?**\n\nYes! Live events are fully supported. This also means you can interact with the mesh in real-time using a repl.\n\n**Is it possible to get a remote callback for emitted mesh events?**\n\nThe mesh does not support remote callbacks. The overhead of safely enabling remote callbacks requires `V8::Persistent<Object>` and the use of `MakeWeak` method through `node-weak`. Since node core doesn't have access to WeakMaps yet it's somewhat cumbersome to use them.\n\nApart from these minor technical issues, using remote callbacks is not a great design choice for distributed applications. In the real world actors will crash and message confirmations may get lost ( even though the event was received and fired on the receiving node ). It is generally a better design choice to stick with an event emitter pattern with no built in confirmations. This same functionality of a remote callback can be achieved using two separate named events and a unique message identifier.\n\n\n\n## Tests\n\n```bash\nnpm test\n```\n","_attachments":{}}