1.1.0 • Published 4 years ago

piesocket-nodejs v1.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

PieSocket NodeJS Server 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 PieSocket Server SDK, if you are looking for Client SDK (to use with Frontend on browsers), please see PieSocketJS.

Installation

Yarn

yarn add piesocket-nodejs

NPM

npm i piesocket-nodejs

Importing

Import module:

const PieSocket = require("piesocket-nodejs");

Publishing messages

  1. Initialize the PieSocket class:
var piesocket = new PieSocket({
    clusterId: 'YOUR_CLUSTER_ID',
    apiKey: 'YOUR_API_KEY',
    secret: 'YOUR_API_SECRET'
});
  1. Publish events:
piesocket.publish("channel", "event-name" , data, meta);

Channel ID can be a string or number, data should be JSON. meta can be null or JSON.

Supported Methods

List of available methods on the PieSocket object

MethodDescriptionReturns
publish(channel ,event ,data ,meta)Publish an event to a channelPromise

Configuration

Complete list of allowed configuration options

OptionDescriptionDefault
apiKeyYour PieSocket API keynull
clusterIdYour API key's cluster IDdemo
secretYour PieSocket API keynull

Reference