Package Exports
- piesocket-nodejs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (piesocket-nodejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
PieSocket NodeJS SDK
A NodeJS Library for PieSocket Channels.
PieSocket Channels are a medium for clients and servers to communicate in real-time. Client-to-client communications are also supported.
Note: This package is for server-side publishing, if you are looking for the package to use on the Frontend for subscribing, please see PieSocketJS.
Installation
Yarn
yarn add piesocket-nodejsNPM
npm i piesocket-nodejsImporting
Import module:
const PieSocket = require("piesocket-nodejs");Publishing messages
- Initialize the PieSocket class:
var piesocket = new PieSocket({
clusterId: 'YOUR_CLUSTER_ID',
apiKey: 'YOUR_API_KEY',
secret: 'YOUR_API_SECRET'
});- Publish:
piesocket.publish(channelId, data);Channel ID can be a string or number,
data should be a String or JSON.
Supported Methods
List of available methods on the PieSocket object
| Method | Description | Returns |
|---|---|---|
| publish(channelId, message) | Publish to a channel | Promise object |
Configuration
Complete list of allowed configuration options
| Option | Description | Default |
|---|---|---|
| apiKey | Your PieSocket API key | null |
| clusterId | Your API key's cluster ID | demo |
| secret | Your PieSocket API key | null |
Reference
- PieSocketJS: PieSocket Browser SDK
- Documentation: PieSocket WebSocket docs