node-quic
A wrapper around fidm/quic, node-quic is a dead simple stream based QUIC server / client for use in node.js.
node-quic is a simple way to bring QUIC / UDP into your application.
Installation
npm install node-quic
Usage
import quic from 'node-quic'
const port = 1234
const address = '127.0.0.1'
quic.listen(port, address)
.then(() => {})
.onError((error) => {})
.onData(
(data, stream, buffer) => {}
)
quic.send(port, address, data)
.then(() => {})
.onError((error) => {})
.onData((data, buffer) => {})
There are also a few utility functions:
quic.stopListening()
quic.getServer()
quic.getAddress()
For example:
const port = 1234
const address = '127.0.0.1'
quic.listen(port, address)
.onData((data, stream, buffer) => {
const parsedData = JSON.parse(data)
console.log(parsedData)
stream.write(parsedData)
})
quic.send(port, address, { hello: 'world!' })
.onData(data => {
const parsedData = JSON.parse(data)
console.log(parsedData)
quic.stopListening()
})
Easy Peasy. Enjoy!