mirror of
https://github.com/fluencelabs/registry.git
synced 2025-04-25 02:02:14 +00:00
23 lines
815 B
JavaScript
23 lines
815 B
JavaScript
import { initTopicAndSubscribe, findSubscribers } from "./export.js";
|
|
import { createClient } from "@fluencelabs/fluence";
|
|
import { krasnodar } from "@fluencelabs/fluence-network-environment";
|
|
|
|
async function main() {
|
|
// connect to the Fluence network
|
|
const client = await createClient(krasnodar[1]);
|
|
let topic = "myTopic";
|
|
let value = "myValue";
|
|
// create topic (if not exists) and subscribe on it
|
|
await initTopicAndSubscribe(client, client.relayPeerId, topic, value, client.relayPeerId, null);
|
|
// find other peers subscribed to that topic
|
|
let subscribers = await findSubscribers(client, client.relayPeerId, topic);
|
|
console.log("found subscribers:", subscribers);
|
|
}
|
|
|
|
main()
|
|
.then(() => process.exit(0))
|
|
.catch(error => {
|
|
console.error(error);
|
|
process.exit(1);
|
|
});
|