PieSocket logo

Overview

PieSocket lets you integrate dynamics into your application by enabling two-way communications with its "Managed Websocket API" and "PubSub SDKs."

What is WebSocket

A WebSocket connection is a long-lived bi-directional HTTP connection that stays open in your browser/app/client and can receive data instantly. All modern browsers support WebSockets.

We provide a secure WebSocket server API that takes away your worries of setting up and managing a scalable WebSocket server infrastructure.

See the getting started guide section for examples on how to use the service.

WebSocket Server API

Using PieSocket's WebSocket API, you can focus more on your product and leave the complexities of the scalable bi-directional server infrastructure to us.

{primary} wss://CLUSTER_ID.websocket.me/v3/CHANNEL_ID?api_key=API_KEY

Following is a demo API endpoint:

wss://demo.websocket.me/v3/1?api_key=oCdCMcMPQpbvNjUIzqtvF1d2X2okWpDQj4AwARJuAgtjhzKxVEjQU6IdCjwm

Parameters

Cluster ID

You can find the Cluster-ID with API key credentials in your PieSocket account.

API Key

You can generate an API Keys from your PieSocket account for free.

Channel ID

It can be any string with allowed characters mentioned below.

When a message is sent, it is distributed only to the members of the sender's channel.

Example: Let's say you are using two WebSocket APIs,

-  wss://demo.websocket.me/v3/1/1998?apiKey=hidden
-  wss://demo.websocket.me/v3/1/1999?apiKey=hidden

and, there are 5 users connected to each channel. When a user from channel 1998 sends a message, it is received by the members of the channel 1998 only.

Choosing a channel ID:

- Channel ID can contain characters [a-z], [A-Z], [0-9] 
- Channel ID can contain special characters _ (underscore) and - (hyphen).
- Change Channel ID when you want to isolate a group of users for data transmission.
- Sender of a message will not receive their own message, use `notify_self` to enable.

Notify Self

By default, the WebSocket server does not publish a message to its original sender. For example, if there are three peers A, B, and C, connected to your channel, messages sent by A will only by delivered to B and C.

To enable receiving self messages, add &notify_self to your server connection URL as shown below.

wss://demo.websocket.me/v3/CHANNEL_ID?api_key=API_KEY&notify_self

Command messages

Command messages are reserved string messages that start with cmd_, and they are used to send queries to the WebSocket server.

Following is a list of command messages:

cmd_status

Responds with number of connected clients to the channel.

Example: Sending "cmd_status" to a PieSocket channel, results in following response: {"system":{"connection_count":1}}

cmd_ping

Responds with "pong"

Example: Sending "cmd_ping" to a PieSocket channel, results in following response: {"system":"pong"}

Getting started

See the getting started guide section for examples on how to use the service.