프로젝트
GitHub에서 보기
tj/punt
소개
Elegant UDP messaging for nodejs
생산성 및 자동화측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalPunt
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
관련 프로젝트 살펴보기
불러오는 중…