{"id":21937653,"url":"https://github.com/cap32/o--o","last_synced_at":"2026-04-28T21:04:16.804Z","repository":{"id":88318785,"uuid":"145194092","full_name":"Cap32/o--o","owner":"Cap32","description":null,"archived":false,"fork":false,"pushed_at":"2018-08-18T06:34:49.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-27T13:48:28.998Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cap32.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2018-08-18T05:52:32.000Z","updated_at":"2023-03-04T05:34:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"49d726a2-5d89-4624-90ac-aa2572ace403","html_url":"https://github.com/Cap32/o--o","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap32%2Fo--o","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap32%2Fo--o/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap32%2Fo--o/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap32%2Fo--o/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cap32","download_url":"https://codeload.github.com/Cap32/o--o/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244967914,"owners_count":20540035,"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":[],"created_at":"2024-11-29T01:21:10.417Z","updated_at":"2026-04-28T21:04:11.777Z","avatar_url":"https://github.com/Cap32.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# o--o\n\n[WIP] A lightweight elegant WebSocket in Node.js\n\n## Features\n\n- Support `Pub / Sub` pattern\n- Support `Push / Pull` pattern\n- Support `Request / Reply` pattern\n- Promise based\n\n## Events\n\n- `error` (err) when an un-handled socket error occurs\n- `close` when server or connection is closed\n- `pub` (...args) when a message publishes\n- `sub` (...args) when a message subscription occurs\n- `req` (...args) when a message requests\n- `rep` (...args) when a message reply occurs\n\n## Usages\n\n**Server.js**\n\n```js\nimport { Server } from 'o--o';\n\n(async function () {\n  try {\n    const server = await Server.create(9994);\n    server.sub('greeting', (msg) =\u003e {\n      console.log('received', msg);\n    });\n  } catch (err) {\n    console.errer(err);\n  }\n}());\n```\n\n**Client.js**\n\n```js\nimport { Client } from 'o--o';\n\n(async function () {\n  try {\n    const client = await Client.connect(`ws://127.0.0.1:9994`);\n    await client.pub('greeting', 'hello');\n  } catch (err) {\n    console.errer(err);\n  }\n}());\n```\n\n### Pattern: pub / sub\n\n**Server.js**\n\n```js\nserver.sub('greeting', (msg) =\u003e {\n  console.log('received', msg);\n});\n```\n\n**Client.js**\n\n```js\nconst client = await Client.connect(`ws://127.0.0.1:9994`);\nawait client.pub('greeting', 'hello');\n```\n\n### Pattern: req / rep\n\n**Server.js**\n\n```js\nawait server.rep('greeting', async (msg) =\u003e {\n  return msg === 'hello' ? 'world' : 'hi';\n});\n```\n\n**Client.js**\n\n```js\nconst client = await Client.connect(`ws://127.0.0.1:9994`);\nawait client.req('greeting', 'hello');\n```\n\n## License\n\nMIT © Cap32\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap32%2Fo--o","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcap32%2Fo--o","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap32%2Fo--o/lists"}