npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

piesocket-js

v5.1.0

Published

PieSocket Javascript Client

Downloads

2,975

Readme

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

| Option | Description | Default | | ----------------------------- | ----------------------------------------------------------------------------- | -------------- | | apiKey | Required, Your PieSocket API key. | Demo key | | clusterId | Your API key's cluster ID. | demo | | clusterDomain | Custom domain, if you have configured one in your account. | null | | consoleLogs | Logs useful connection info if set to true. | false | | notifySelf | Receive messages sent by self, pass 0 to disabled. | 1 | | jwt | JWT authentication token, skips authentication endpoint call. | null | | presence | Enable presence events on any channel, pass 1 to enabled. | 0 | | authEndpoint | Authentication endpoint for private channels. | /broadcasting/auth | | authHeaders | Headers to include with authEndpoint call. | {} | | forceAuth | Force authentication on all channels. | false | | userId | User ID, used when user does not exists in JWT payload. | anonymous | | blockchainTestMode | Enable/disable test mode, defaults to false i.e., Ethereum main network. Set to true for Rinkeby test network. | false | | blockchainGasFee | Gas fee to set on Ethereum contract calls | 41000 |

PieSocket Object

List of available methods on the PieSocket object

| Method | Description | Returns | | ----------------------------- | ----------------------------------------------------------------------------- | -------------- | | 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

| Method | Description
| ----------------------------- | ----------------------------------------------------------------------------- | 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 [email protected]: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