Convert a socket.io socket into a stream.
npm install @geut/socket.io-streamify


> Convert your socket.io sockets into duplex streams.
This module is based on the work of websocket-stream we modified the code to support socket.io
```
$ npm install @geut/socket.io-streamify
javascript
const streamify = require('@geut/socket.io-streamify')
const stream = streamify('http://localhost:3000')stream.on('data', chunk => {
console.log(chunk.toString('utf8'))
})
stream.write('hello from client')
`$3
`javascript
const { createServer } = require('@geut/socket.io-streamify')createServer(3000, stream => {
stream.on('data', (data) => {
console.log(data.toString('utf8'))
stream.write('hi from server')
})
})
` API
####
const stream = streamify(url|socket, [options])#### Options
The available options differs depending on if you use this module in the browser or with node.js.
#####
options.browserBufferSizeHow much to allow the socket.bufferedAmount to grow before starting to throttle writes. This option has no effect in node.js.
Default:
1024 * 512 (512KiB)#####
options.browserBufferTimeoutHow long to wait before checking if the socket buffer has drained sufficently for another write. This option has no effect in node.js.
Default:
1000 (1 second)#####
options.objectModeSend each chunk on its own, and do not try to pack them in a single
websocket frame.
Default:
false#####
options.binaryAlways convert to
Buffer in Node.js before sending.
Forces options.objectMode to false.Default:
true#####
options.socketIOOptions for the socketIO instance.
####
const io = streamify.createServer(port|server, [options], [callback])#### Options
Options are part of Socket.IO server.
#### Callback
function (stream) {}Execute it every time the server gets a new socket connection.
####
io.onStream(stream => {})Add a listener for a
stream event.####
io.removeOnStream(stream => {})Remove a listener for a
stream` event.:bug: If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.
:busts_in_silhouette: Ideas and contributions to the project are welcome. You must follow this guideline.
MIT © A GEUT project