Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "node-quic", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A wrapper around fidm/quic, node-quic is a dead simple stream based QUIC server / client for use in node.js.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -21,3 +21,3 @@ # node-quic | ||
const port = 1234 | ||
const port = 1234 | ||
const address = '127.0.0.1' // default | ||
@@ -82,2 +82,33 @@ | ||
For example: | ||
```js | ||
const port = 1234 | ||
const address = '127.0.0.1' | ||
// First we listen. | ||
quic.listen(port, address) | ||
.onData((data, stream, buffer) => { | ||
const parsedData = JSON.parse(data) | ||
console.log(parsedData) // { hello: 'world!' } | ||
// Once the data is received and logged, we'll send it right back | ||
stream.write(parsedData) | ||
}) | ||
// Now we send the data to the server. | ||
quic.send(port, address, { hello: 'world!' }) | ||
.onData(data => { | ||
// This is the data that was sent right back | ||
const parsedData = JSON.parse(data) | ||
console.log(parsedData) // { hello: 'world!' } | ||
// now we can stop the server from listening if we want this to be a one-off | ||
quic.stopListening() | ||
}) | ||
``` | ||
Easy Peasy. Enjoy! |
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
46278
113