mirror of
https://github.com/fluencelabs/registry.git
synced 2025-06-29 07:41:38 +00:00
Update JS SDK to 0.12 (#54)
This commit is contained in:
@ -1,18 +1,17 @@
|
||||
import { FluencePeer } from "@fluencelabs/fluence";
|
||||
import { Fluence } from "@fluencelabs/fluence";
|
||||
import { krasnodar } from "@fluencelabs/fluence-network-environment";
|
||||
import { initTopicAndSubscribe, findSubscribers } from "./generated/export";
|
||||
|
||||
async function main() {
|
||||
// connect to the Fluence network
|
||||
const peer = FluencePeer.default;
|
||||
await peer.init({ connectTo: krasnodar[1] });
|
||||
await Fluence.start({ connectTo: krasnodar[1] });
|
||||
let topic = "myTopic";
|
||||
let value = "myValue";
|
||||
// create topic (if not exists) and subscribe on it
|
||||
let relay = peer.connectionInfo.connectedRelay!;
|
||||
await initTopicAndSubscribe(peer, topic, value, relay, null);
|
||||
let relay = Fluence.getStatus().relayPeerId;
|
||||
await initTopicAndSubscribe(topic, value, relay, null);
|
||||
// find other peers subscribed to that topic
|
||||
let subscribers = await findSubscribers(peer, topic);
|
||||
let subscribers = await findSubscribers(topic);
|
||||
console.log("found subscribers:", subscribers);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user