项目
在 GitHub 查看
tj/punt
关于
Elegant UDP messaging for nodejs
效率与自动化实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Punt
A small layer on top of node's core UDP module to make fast volatile messaging even simpler. Punt uses the tiny AMP prototol to serialize buffer, string, and json arguments.
Installation
$ npm install punt
Example
A small in-proc example of a server with three clients:
var punt = require('punt');
var server = punt.bind('0.0.0.0:5000');
var a = punt.connect('0.0.0.0:5000');
var b = punt.connect('0.0.0.0:5000');
var c = punt.connect('0.0.0.0:5000');
server.on('message', function(msg){
console.log(msg);
});
setInterval(function(){
a.send({ hello: 'world' });
}, 150);
setInterval(function(){
b.send('hello world');
}, 150);
setInterval(function(){
c.send(Buffer.from('hello'));
}, 150);
yielding:
<Buffer 68 65 6c 6c 6f>
hello world
{ hello: 'world' }
<Buffer 68 65 6c 6c 6f>
hello world
{ hello: 'world' }
...
API
Server(addr)
Bind to the given addr.
Client(addr)
Connect to the given addr.
Client#send(...)
Send one or more arguments a single atomic message. The following types are supported through AMP:
- strings
- buffers
- objects (serialized as JSON)
License
MIT
探索相关项目
加载中…