Javascript Client SDK
This Javascript SDK allows a WebApp to communicate with an SQLite Cloud cluster using a WebSocket.
The main WebSocket is used to:
- execute commands
- get channels list
- create a new channel
- remove an existing channel
- send notifications to a specific channel
- listen a channel
- listen a database table
- unlisten a channel
- unlisten a table
An optional secondary Pub/Sub WebSocket is used to receive notifications sent by others users (only if at least one channel/table listening command is performed).
How to use
To get started you have to have your API_KEY
and PROJECT_ID
associated to an SQLite Cloud cluster from the SQLiteCloud dashboard.
Once you have your credentials, you can create a new main WebSocket. Every instance of the Javascript Client SDK allows to create a main WebSocket. As describe above main WebSocket is used for all outgoing communications from your WebApp.
It is very important to emphasize that once you have created and registered channels or tables for PUB/SUB communications, if you are only interested in receiving messages, you can close the main WebSocket, leaving open only the Pub/Sub WebSocket.
Example
To test the functionalities of the SDK, we prepared a sample API test project (source code).
To demonstrate the power of the Pub/Sub capabilities built into SQLite Cloud we prepared a sample Chat WebApp (source code).