{"id":19901546,"url":"https://github.com/cettia/cettia-javascript-client","last_synced_at":"2025-05-02T23:31:52.755Z","repository":{"id":28918025,"uuid":"32443058","full_name":"cettia/cettia-javascript-client","owner":"cettia","description":"A lightweight JavaScript client for browser-based and Node-based Cettia applications","archived":false,"fork":false,"pushed_at":"2024-08-27T20:16:44.000Z","size":256,"stargazers_count":15,"open_issues_count":5,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T18:04:32.984Z","etag":null,"topics":["cettia","client","comet","javascript","long-polling","real-time","streaming","websocket"],"latest_commit_sha":null,"homepage":"https://cettia.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cettia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-18T06:57:53.000Z","updated_at":"2024-04-19T10:59:55.000Z","dependencies_parsed_at":"2024-12-31T01:41:06.573Z","dependency_job_id":"04a837e4-6eb3-444e-8785-386b636790f3","html_url":"https://github.com/cettia/cettia-javascript-client","commit_stats":{"total_commits":49,"total_committers":3,"mean_commits":"16.333333333333332","dds":0.04081632653061229,"last_synced_commit":"1ceed7794e003f777d69f0cb2b8c13800750295d"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cettia%2Fcettia-javascript-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cettia%2Fcettia-javascript-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cettia%2Fcettia-javascript-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cettia%2Fcettia-javascript-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cettia","download_url":"https://codeload.github.com/cettia/cettia-javascript-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252122276,"owners_count":21698305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cettia","client","comet","javascript","long-polling","real-time","streaming","websocket"],"created_at":"2024-11-12T20:15:29.806Z","updated_at":"2025-05-02T23:31:52.345Z","avatar_url":"https://github.com/cettia.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cettia JavaScript Client\n\nCettia 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](https://www.npmjs.com/package/cettia-client).\n\n## Installation\n\n### `script` tag\n\nAdd the following script tag to your HTML.\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/cettia-client/cettia-browser.min.js\"\u003e\u003c/script\u003e\n```\n```javascript\nwindow.cettia;\n```\n\n### Bundler\n\nInstall and load the package.\n\n```\nnpm install cettia-client\n```\n```javascript\nvar cettia = require('cettia-client/cettia-bundler');\n```\n\nNote: You should use this way to use Cettia in React Native.\n\n### Node\n\nInstall and load the package.\n\n```\nnpm install cettia-client\n```\n```javascript\nvar cettia = require('cettia-client');\n```\n\n## Usage\n\nCettia 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.\n\n```javascript\nconst cettia = require(\"cettia-client\");\nconst username = \"DH\";\nconst uri = `http://localhost:8080/cettia?username=${encodeURIComponent(username)}`;\nconst socket = cettia.open(uri);\n\nconst addMessage = ({sender, text}) =\u003e console.log(`${sender} sends ${text}`);\nsocket.on(\"message\", addMessage);\n\nconst addSystemMessage = text =\u003e addMessage({sender: \"system\", text});\nsocket.on(\"connecting\", () =\u003e addSystemMessage(\"The socket starts a connection.\"));\nsocket.on(\"open\", () =\u003e addSystemMessage(\"The socket establishes a connection.\"));\nsocket.on(\"close\", () =\u003e addSystemMessage(\"All transports failed to connect or the connection was disconnected.\"));\nsocket.on(\"waiting\", (delay) =\u003e addSystemMessage(`The socket will reconnect after ${delay} ms`));\n\n// Once a socket has opened, sends a message every 5 seconds\nsocket.once(\"open\", () =\u003e setInterval(() =\u003e socket.send(\"message\", {text: `A message - ${Date.now()}`}), 5000));\n```\n\nBesides 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.\n\n## See Also\n\n- [Getting Started](https://cettia.io/guides/getting-started/)\n- [Cettia Starter Kit](https://github.com/cettia/cettia-starter-kit)\n- [Building Real-Time Web Applications With Cettia](https://cettia.io/guides/cettia-tutorial) \n- [Various demo applications using Cettia and Spring 5](https://github.com/ralscha/cettia-demo) by Ralph Schaer\n- [Real-time messaging with Cettia and Spring Boot](https://golb.hplar.ch/2019/01/cettia-springboot.html) by Ralph Schaer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcettia%2Fcettia-javascript-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcettia%2Fcettia-javascript-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcettia%2Fcettia-javascript-client/lists"}