Cettia JavaScript Client
Cettia JavaScript Client is a lightweight JavaScript client for browser-based and Node-based application and distributed via the npm registry with the name, cettia-client.
Installation
script
tag
Add the following script tag to your HTML.
windowcettia;
Bundler
Install and load the package.
npm install cettia-client
var cettia = ;
Note: You should use this way to use Cettia in React Native.
Node
Install and load the package.
npm install cettia-client
var cettia = ;
Usage
Cettia will be familiar to people using other real-time web frameworks and libraries. You open a socket and send and receive events with Cettia's API. Here is the main.js contents which is a Node example of the Cettia Starter Kit.
const cettia = ;const username = "DH";const uri = `http://localhost:8080/cettia?username=`;const socket = cettia; const addMessage = console;socket; const addSystemMessage = ;socket;socket;socket;socket; // Once a socket has opened, sends a message every 5 secondssocket;
Besides a Node example, the Cettia starter kit provides Web example and React Native example which demonstrate how you can use Cettia JavaScript Client in various runtime environment.