How to use the fluence.directConnect function in fluence

To help you get started, we’ve selected a few fluence examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fluencelabs / fluence / fluence-js / src / examples / fluence-streamr / index.js View on Github external
import StreamrClient from 'streamr-client'
import * as fluence from "fluence"

const streamrClient = new StreamrClient();
const fluenceSession = fluence.directConnect("localhost", 29057);

const createTableQuery = "CREATE TABLE polution_uusimaa(id varchar(128), location varchar(128), parameter varchar(128), " +
    "value double, unit varchar(128), country varchar(128), city varchar(128), latitude double, " +
    "longitude double, local varchar(128), utc varchar(128))";

const deleteQuery = "DELETE FROM polution_uusimaa";

fluenceSession.invoke(deleteQuery).result().then((r) => console.log(r.asString()));

fluenceSession.invoke(createTableQuery)
    .result() // to return promise and wait for result we need to call `result()` function
    .then((r) => console.log(r.asString())); // `asString()` decodes bytes format to string

function insertQuery(data) {
    const query = `INSERT INTO polution_uusimaa VALUES ('${data.id}', '${data.location}', '${data.parameter}', ${data.value}, ` +
        `'${JSON.stringify(data.unit)}', '${data.country}', '${data.city}', ${data.latitude}, ${data.longitude}, '${data.local}', '${data.utc}')`;
github fluencelabs / fluence / fluence-js / src / examples / todo-list / index.js View on Github external
// *****
// *** import `fluence` to start work with real-time cluster
// *****

import * as fluence from "fluence"

// *****
// *** create default session with credentials for interaction with the cluster,
// *** you can change the port if you want to interact with another node or your cluster have other ports
// *****

const session = fluence.directConnect("localhost", 25057);

window.onload = function () {

    //select elements and assign them to vars
    const newTask = document.querySelector('#new-task');
    const addTaskBtn = document.querySelector('#addTask');

    const toDoUl = document.querySelector(".todo-list ul");
    const completeUl = document.querySelector(".complete-list ul");

    const todoLoader = document.querySelector("#todo-loader");
    const doneLoader = document.querySelector("#done-loader");

    // *****
    // *** define table names that will store info about tasks
    // *****

fluence

the browser js-libp2p client for the Fluence network

Apache-2.0
Latest version published 4 years ago

Package Health Score

40 / 100
Full package analysis