5.1.0 • Published 1 year ago

piesocket-js v5.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

PieSocket JavaScript Client

A JavaScript Library for PieSocket Realtime.

Note: This package is PieSocket Client SDK (to be used with frontend on browsers), if you are looking for the NodeJS Server SDK, please see PieSocket-NodeJS.

Installation

Yarn

yarn add piesocket-js

NPM

npm i piesocket-js

CDN

<script src="https://unpkg.com/piesocket-js@5"></script>

Importing

Import module:

import PieSocket from 'piesocket-js';

With CDN/Browser:

Use the PieSocket.default global variable, e.g. var piesocket = new PieSocket.default({...})

How To Use

PieSocketJS offers Channels and Portals.

Channels

Channels are realtime PubSub connections over WebSocket, they allow you to:

  • Subscribe to events on client side
  • Publish events from server
  • Publish events from client with C2C feature.

See the Channels documentation to learn more about how to use Channels.

Portals

Portals are programmable video streams over WebRTC, they allow you to build powerful video applications.

See the Portals documentation to learn more about how to use Portals.

Configuration

Complete list of allowed configuration options

OptionDescriptionDefault
apiKeyRequired, Your PieSocket API key.Demo key
clusterIdYour API key's cluster ID.demo
clusterDomainCustom domain, if you have configured one in your account.null
consoleLogsLogs useful connection info if set to true.false
notifySelfReceive messages sent by self, pass 0 to disabled.1
jwtJWT authentication token, skips authentication endpoint call.null
presenceEnable presence events on any channel, pass 1 to enabled.0
authEndpointAuthentication endpoint for private channels./broadcasting/auth
authHeadersHeaders to include with authEndpoint call.{}
forceAuthForce authentication on all channels.false
userIdUser ID, used when user does not exists in JWT payload.anonymous
blockchainTestModeEnable/disable test mode, defaults to false i.e., Ethereum main network. Set to true for Rinkeby test network.false
blockchainGasFeeGas fee to set on Ethereum contract calls41000

PieSocket Object

List of available methods on the PieSocket object

MethodDescriptionReturns
subscribe(channelId)Subscribe to a channel.Channel Object
unsubscribe(channelId)Un-subscribe from a channel.Boolean
getConnections()Get list of all active connections/channels for this client.Object

Channel Object

List of available methods on the Channel object

MethodDescription
listen("event-name", callback)Listen to an event.
publish("event-name", data, meta)Publish message from client.
getMemberByUUID(uuid)Get a Presence member from their uuid.
on("lifecycle-event", callback)Listen to lifecycle events on the native WebSocket connection.
confirmOnBlockchain(event, transaction_hash)Create a proof-of-witness for a Blockchain message, on receiver's end.

Development

  • Clone the repo git clone git@github.com:piesocket/piesocket-js.git
  • Run npm install
  • Run npm start
  • Open http://localhost:8080 in browser

Now you can interactively test the SDK, add features and fix bugs.

Documentation: PieSocket Realtime Docs

5.1.0

1 year ago

5.0.9

2 years ago

5.0.8

2 years ago

5.0.7

2 years ago

5.0.6

2 years ago

5.0.5

2 years ago

5.0.4

2 years ago

5.0.3

2 years ago

5.0.1

2 years ago

5.0.10

2 years ago

5.0.11

2 years ago

5.0.12

2 years ago

5.0.13

2 years ago

5.0.14

2 years ago

5.0.15

2 years ago

5.0.16

2 years ago

5.0.17

2 years ago

4.2.3

2 years ago

4.2.2

2 years ago

4.1.0

2 years ago

4.2.1

2 years ago

4.0.1

3 years ago

3.0.7

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.2.5

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.4.0

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago