Update JS SDK to 0.12 (#54)

This commit is contained in:
folex
2021-09-13 13:44:30 +03:00
committed by GitHub
parent 899d049ff0
commit 95b74bdeb3
4 changed files with 59 additions and 2668 deletions

View File

@ -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);
}