bloggify-ws
v4.0.3
Published
Websockets for Bloggify Actions!
Downloads
16
Maintainers
Readme
bloggify-ws
Websockets for Bloggify Actions!
:cloud: Installation
# Using npm
npm install --save bloggify-ws
# Using yarn
yarn add bloggify-ws
:clipboard: Example
///// Client (browser)
const ws = require("bloggify-ws");
const socket = ws("my-action", (err, data, cb) => {
if (err) {
/* The server sent an error */
/* Or got disconnected (e.g. server down, internet down) */
}
/* do something with data coming from the server */
// ...
/* Send something back to the server */
cb(null, {
foo: "bar"
})
})
// Send data to the server
socket.data(/* ... */)
// Send an error to the server
socket.error(/* ... */)
///// Server
///// (in `app/actions`)
const action = Bloggify.actions.ws("my-action", (err, data, cb) => {
if (err) {
/* The client sent an error */
}
/* do something with data coming from the client */
// ...
/* Send something back to the client */
cb(null, {
foo: "bar"
})
})
// Send data to the client
action.data(/* ... */)
// Send an error to the client
action.error(/* ... */)
:question: Get Help
There are few ways to get help:
- Please post questions on Stack Overflow. You can open issues with questions, as long you add a link to your Stack Overflow question.
- For bug reports and feature requests, open issues. :bug:
:yum: How to contribute
Have an idea? Found a bug? See how to contribute.