udp-messenger
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "udp-messenger", | ||
"version": "0.1.1", | ||
"_args": [ | ||
[ | ||
{ | ||
"raw": "udp-messenger@^0.1.0", | ||
"scope": null, | ||
"escapedName": "udp-messenger", | ||
"name": "udp-messenger", | ||
"rawSpec": "^0.1.0", | ||
"spec": ">=0.1.0 <0.2.0", | ||
"type": "range" | ||
}, | ||
"C:\\Workspace\\src\\github.com\\vijayee\\js-offs" | ||
] | ||
], | ||
"_from": "udp-messenger@>=0.1.0 <0.2.0", | ||
"_id": "udp-messenger@0.1.0", | ||
"_inCache": true, | ||
"_installable": true, | ||
"_location": "/udp-messenger", | ||
"_nodeVersion": "6.3.1", | ||
"_npmOperationalInternal": { | ||
"host": "packages-16-east.internal.npmjs.com", | ||
"tmp": "tmp/udp-messenger-0.1.0.tgz_1473684608183_0.8804111646022648" | ||
}, | ||
"_npmUser": { | ||
"name": "vijayee", | ||
"email": "vijayee.kulkaa@hushmail.com" | ||
}, | ||
"_npmVersion": "3.10.3", | ||
"_phantomChildren": {}, | ||
"_requested": { | ||
"raw": "udp-messenger@^0.1.0", | ||
"scope": null, | ||
"escapedName": "udp-messenger", | ||
"name": "udp-messenger", | ||
"rawSpec": "^0.1.0", | ||
"spec": ">=0.1.0 <0.2.0", | ||
"type": "range" | ||
}, | ||
"_requiredBy": [ | ||
"/" | ||
], | ||
"_resolved": "https://registry.npmjs.org/udp-messenger/-/udp-messenger-0.1.0.tgz", | ||
"_shasum": "fd079d0f9ff6168af09089cbd2f8347280f2608e", | ||
"_shrinkwrap": null, | ||
"_spec": "udp-messenger@^0.1.0", | ||
"_where": "C:\\Workspace\\src\\github.com\\vijayee\\js-offs", | ||
"author": { | ||
"name": "Vijayee Kulkaa" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/vijayee/udp-messages/issues" | ||
}, | ||
"dependencies": { | ||
"block-stream2": "^1.1.0", | ||
"protocol-buffers": "^3.1.6", | ||
"streamifier": "^0.1.1", | ||
"through2": "^2.0.1" | ||
}, | ||
"description": "Send messages over udp in small chunks", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"devDependencies": {}, | ||
"directories": {}, | ||
"dist": { | ||
"shasum": "fd079d0f9ff6168af09089cbd2f8347280f2608e", | ||
"tarball": "https://registry.npmjs.org/udp-messenger/-/udp-messenger-0.1.0.tgz" | ||
}, | ||
"gitHead": "7616ab3420263adb5e608c75f391123f16b420f0", | ||
"homepage": "https://github.com/vijayee/udp-messages#readme", | ||
"keywords": [ | ||
@@ -15,14 +76,21 @@ "udp", | ||
], | ||
"author": "Vijayee Kulkaa", | ||
"license": "ISC", | ||
"repository" : | ||
{ "type" : "git" | ||
, "url" : "https://github.com/vijayee/udp-messages" | ||
"main": "src/index.js", | ||
"maintainers": [ | ||
{ | ||
"name": "vijayee", | ||
"email": "vijayee.kulkaa@hushmail.com" | ||
} | ||
], | ||
"name": "udp-messenger", | ||
"optionalDependencies": {}, | ||
"readme": "ERROR: No README data found!", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/vijayee/udp-messages.git" | ||
}, | ||
"dependencies": { | ||
"block-stream2": "^1.1.0", | ||
"protocol-buffers": "^3.1.6", | ||
"streamifier": "^0.1.1", | ||
"through2": "^2.0.1" | ||
} | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"version": "0.2.0" | ||
} |
@@ -7,3 +7,3 @@ #UDP Messenger | ||
let messenger = new Messenger(2000, 54000, 512) // timeout, port, packet size (must be greater than 26 bytes) | ||
let messenger = new Messenger(2000, 54000, 512) // timeout, port, packet size (must be greater than 32 bytes) | ||
messenger.on('message', (msg)=>{}) // when a message is received | ||
@@ -10,0 +10,0 @@ messenger.on('listening', ()=>{}) //when a messenger begins listening |
@@ -124,2 +124,5 @@ 'use strict' | ||
} | ||
if(message.complete){ // case for duplicate packets after message complete | ||
return | ||
} | ||
message.receive(part) | ||
@@ -126,0 +129,0 @@ messageBox.set(id, message) |
@@ -11,2 +11,3 @@ 'use strict' | ||
let _timeout= new WeakMap() | ||
let _complete = new WeakMap() | ||
@@ -25,2 +26,3 @@ class ReceiveMessage extends EventEmitter { | ||
_length.set(this, 0) | ||
_complete.set(this, false) | ||
} | ||
@@ -42,2 +44,5 @@ | ||
} | ||
get complete(){ | ||
return _complete.get(this) | ||
} | ||
@@ -64,2 +69,5 @@ receive (part) { | ||
} | ||
if(chunks[ part.index ] ){ | ||
return | ||
} | ||
chunks[ part.index ] = part.payload | ||
@@ -92,3 +100,6 @@ received++ | ||
let message = Buffer.concat(chunks) | ||
this.emit('received', {msgId: this.msgId, message: message}) | ||
if(!this.complete) { | ||
this.emit('received', { msgId: this.msgId, message: message }) | ||
} | ||
_complete.set(this, true) | ||
} | ||
@@ -95,0 +106,0 @@ } |
@@ -13,3 +13,3 @@ 'use strict' | ||
const EventEmitter = require('events').EventEmitter | ||
const _minSize = 26 | ||
const _minSize = 32 | ||
let _msgId = new WeakMap() | ||
@@ -41,3 +41,3 @@ let _chunks = new WeakMap() | ||
let bufStream = streamifier.createReadStream(buf) | ||
let msgId = crypto.randomBytes(2) | ||
let msgId = crypto.randomBytes(8) | ||
_msgId.set(this, msgId) | ||
@@ -44,0 +44,0 @@ bufStream.pipe(blocker({ size: (packetSize - _minSize), zeroPadding: false })) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
16369
434
1
2