shovon / node-rudp

Reliable UDP for Node.js
33 stars 14 forks source link

callback for send #7

Open mvayngrib opened 9 years ago

mvayngrib commented 9 years ago

would be nice to be able to do something like this:

client.send(data, function() { // the packets this data was split up into have all been acknowledged })

shovon commented 9 years ago

True. Will take a look into it.

shovon commented 9 years ago

Kind of off-topic, but have you used promises? If so, what are your thoughts?

I'm asking because I'm considering having the library return promises for a lot of the async calls. Not for all library calls, but definitely client.send.

mvayngrib commented 9 years ago

I use promises a lot actually...maybe too much. They're good, but I'm not sure I love them as much as I used to.

what would be cool, is being able to pipe to and from an rudp client:

var client = new rudp.Client(socket, address, port)
process.stdin.pipe(client)
client.pipe(process.stdout)
// and of course duplex mode
socket.pipe(client).pipe(socket)

then you could basically use it as a tcp socket

mvayngrib commented 9 years ago

while we're on the subject of cool things, one more would be a pollyfill of node's "net" module over rudp. Then you can plug it right into something like webtorrent and use udp for everything

shovon commented 9 years ago

Good idea.