{"id":14384548,"url":"https://github.com/ipfs-shipyard/ipfs-pubsub-room","last_synced_at":"2025-04-04T16:13:19.981Z","repository":{"id":38705359,"uuid":"94528664","full_name":"ipfs-shipyard/ipfs-pubsub-room","owner":"ipfs-shipyard","description":"IPFS Pubsub room","archived":false,"fork":false,"pushed_at":"2023-03-07T11:06:19.000Z","size":1278,"stargazers_count":289,"open_issues_count":29,"forks_count":42,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-28T03:03:36.336Z","etag":null,"topics":["decentralized","ipfs","p2p","peer"],"latest_commit_sha":null,"homepage":"","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/ipfs-shipyard.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-06-16T09:29:52.000Z","updated_at":"2024-11-21T11:33:02.000Z","dependencies_parsed_at":"2023-02-16T18:15:37.706Z","dependency_job_id":"080c57c6-a796-4486-9342-4f6081f73d91","html_url":"https://github.com/ipfs-shipyard/ipfs-pubsub-room","commit_stats":{"total_commits":117,"total_committers":9,"mean_commits":13.0,"dds":0.3076923076923077,"last_synced_commit":"fca682b7d7aa3f84fee1416ee1b374cdb2afb6f3"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-shipyard%2Fipfs-pubsub-room","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-shipyard%2Fipfs-pubsub-room/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-shipyard%2Fipfs-pubsub-room/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipfs-shipyard%2Fipfs-pubsub-room/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipfs-shipyard","download_url":"https://codeload.github.com/ipfs-shipyard/ipfs-pubsub-room/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247112763,"owners_count":20885606,"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":["decentralized","ipfs","p2p","peer"],"created_at":"2024-08-28T18:01:28.049Z","updated_at":"2025-04-04T16:13:19.965Z","avatar_url":"https://github.com/ipfs-shipyard.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# ipfs-pubsub-room\n\n[![made by Protocol Labs](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)\n[![Freenode](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)\n[![Build Status](https://travis-ci.com/ipfs-shipyard/ipfs-pubsub-room.svg?branch=master)](https://travis-ci.com/ipfs-shipyard/ipfs-pubsub-room)\n\n\u003e Creates a room based on a LibP2P pub-sub channel. Emits membership events, listens for messages, broadcast and direct messeges to peers.\n\n([Demo video](https://t.co/HNYQGE4D4P))\n\n## Install\n\n```bash\n$ npm install ipfs-pubsub-room\n```\n\n## Use\n\nCreating a pubsub room from a LibP2P node\n\n```js\nconst Room = require('ipfs-pubsub-room')\nconst Libp2p = require('libp2p')\n\nconst libp2p = new Libp2p({ ... })\nawait libp2p.start()\n\n// libp2p node is ready, so we can start using ipfs-pubsub-room\nconst room = Room(libp2p, 'room-name')\n```\n\nCreating a pubsub room from an IPFS node\n\n```js\nconst Room = require('ipfs-pubsub-room')\nconst IPFS = require('ipfs')\n\nconst ipfs = await IPFS.create({ ... })\nconst room = Room(ipfs, 'room-name')\n```\n\nOnce we have a room we can listen for messages\n\n```js\nroom.on('peer joined', (peer) =\u003e {\n  console.log('Peer joined the room', peer)\n})\n\nroom.on('peer left', (peer) =\u003e {\n  console.log('Peer left...', peer)\n})\n\n// now started to listen to room\nroom.on('subscribed', () =\u003e {\n  console.log('Now connected!')\n})\n```\n\n## API\n\n### Room (libp2p:LibP2P, roomName:string, options:object)\n\n* `libp2p`: LibP2P node. Must have pubsub activated\n* `roomName`: string, global identifier for the room\n* `options`: object:\n  * `pollInterval`: interval for polling the pubsub peers, in ms. Defaults to 1000.\n\n```js\nconst room = Room(libp2p, 'some-room-name')\n```\n\n## room.broadcast(message)\n\nBroacasts message (string or Uint8Array).\n\n## room.sendTo(cid, message)\n\nSends message (string or Uint8Array) to peer.\n\n## async room.leave()\n\nLeaves room, stopping everything.\n\n## room.getPeers()\n\nReturns an array of peer identifiers (strings).\n\n## room.hasPeer(cid)\n\nReturns a boolean indicating if the given peer is present in the room.\n\n## room.on('message', (message) =\u003e {})\n\nListens for messages. A `message` is an object containing the following properties:\n\n* `from` (string): peer id\n* `data` (Uint8Array): message content\n\n## room.on('peer joined', (cid) =\u003e {})\n\nOnce a peer has joined the room.\n\n## room.on('peer left', (cid) =\u003e {})\n\nOnce a peer has left the room.\n\n## room.on('subscribed',() =\u003e {})\n\nOnce your program has subscribed the topic and announced through IPFS pubsub.\n\n## License\n\nISC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipfs-shipyard%2Fipfs-pubsub-room","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipfs-shipyard%2Fipfs-pubsub-room","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipfs-shipyard%2Fipfs-pubsub-room/lists"}