npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@datasance/iofog-nodejs-sdk

v3.0.1

Published

Native node.js SDK for Eclipse ioFog development.

Downloads

11

Readme

iofog/nodejs-sdk

This module lets you easily build a micro-service. It gives you all the functionality to interact with ioFog via Local API. Additionally some useful methods to work with ioMessage.

  • send new message to ioFog (sendNewMessage)
  • fetch next unread messages from ioFog (getNextMessages)
  • fetch messages for time period and list of accessible publishers (getMessagesByQuery)
  • get config options (getConfig)
  • create ioMessage JSON object (ioMessage)
  • connect to ioFog Control Channel via WebSocket (wsControlConnection)
  • connect to ioFog Message Channel via WebSocket (wsMessageConnection) and publish new message via this channel (wsSendMessage)

Code snippets:

import module:

  var ioFogClient = require('@datasance/iofog-nodejs-sdk');

set up custom host, port and container's ID (in case of no params default values for host and port will be used: 'ioFog', 54321) and pass main callback to trigger when ioFogClient initialization is done:

  ioFogClient.init( 'iofog', 54321, null,
    function () {
        // any code to perform after ioFog is initialized
    }
  );

REST calls

post new ioMessage to ioFog via REST call:

  ioFogClient.sendNewMessage(
    ioFogClient.ioMessage(
                 {
                     'tag': 'Bosch Camera 8798797',
                     'groupid': 'group1',
                     'sequencenumber': 2,
                     'sequencetotal': 100,
                     'priority': 5,
                     'authid': 'auth',
                     'authgroup': 'authgrp',
                     'chainposition': 10,
                     'hash': 'hashingggg',
                     'previoushash': 'prevhashingggg',
                     'nonce': 'nounceee',
                     'difficultytarget': 30,
                     'infotype': 'image/jpeg',
                     'infoformat': 'base64',
                     'contextdata': 'gghh',
                     'contentdata' : 'sdkjhwrtiy8wrtgSDFOiuhsrgowh4touwsdhsDFDSKJhsdkljasjklweklfjwhefiauhw98p328'
                 }),
    {
        'onBadRequest':
            function(errorMsg) {
                console.log(errorMsg);
            },
        'onMessageReceipt':
            function(messageId, timestamp) {
                console.log(messageId + ' : ' + timestamp);
            },
        'onError':
            function(error) {
                console.log(error);
            }
    }
  );

get list of ioMessages by time frame for accessible publishers from ioFog via REST call

  ioFogClient.getMessagesByQuery( Date.now(), Date.now(), ['PUBLISHER'],
    {
        'onBadRequest':
            function(errorMsg) {
                console.log(errorMsg);
            },
        'onMessagesQuery':
            function(timeframestart, timeframeend, messages) {
                console.log(timeframestart + ':' + timeframeend);
                console.log(messages);
            },
        'onError':
            function(error) {
                console.log(error);
            }
    }
  );

get list of next unread ioMessages via REST call

  ioFogClient.getNextMessages(
    {
        'onBadRequest':
            function(errorMsg) {
                console.log(errorMsg);
            },
        'onMessages':
            function(messages) {
                console.log(messages);
            },
        'onError':
            function(error) {
                console.log(error);
            }
    }
  );

get container's config via REST call

  ioFogClient.getConfig(
    {
        'onBadRequest':
            function(errorMsg) {
                console.log(errorMsg);
            },
        'onNewConfig':
            function(config) {
               console.log(config);
            },
        'onError':
            function(error) {
                console.log(error);
            }
    }
  );

get Agent's Edge Resources via REST call

  ioFogClient.getEdgeResources(
    {
        'onBadRequest':
            function(errorMsg) {
                console.log(errorMsg);
            },
        'onEdgeResources':
            function(edgeResources) {
               console.log(edgeResources);
            },
        'onError':
            function(error) {
                console.log(error);
            }
    }
  );

WebSocket(WS) calls

open WS Message Channel to ioFog with callback that will be executed on open socket (in this example - sends new message via this channel)

  ioFogClient.wsMessageConnection(
    function(ioFogClient) {
        var ioMsg = ioFogClient.ioMessage(
                 {
                     'tag': 'Bosch Camera 8798797',
                     'groupid': 'group1',
                     'sequencenumber': 2,
                     'sequencetotal': 100,
                     'priority': 5,
                     'authid': 'auth',
                     'authgroup': 'authgrp',
                     'chainposition': 10,
                     'hash': 'hashingggg',
                     'previoushash': 'prevhashingggg',
                     'nonce': 'nounceee',
                     'difficultytarget': 30,
                     'infotype': 'image/jpeg',
                     'infoformat': 'base64',
                     'contextdata': 'gghh',
                     'contentdata' : 'sdkjhwrtiy8wrtgSDFOiuhsrgowh4touwsdhsDFDSKJhsdkljasjklweklfjwhefiauhw98p328'
                 });
        ioFogClient.wsSendMessage(ioMsg);
    },
    {
        'onMessages':
            function(messages) {
                console.log(messages);
            },
        'onMessageReceipt':
            function(messageId, timestamp) {
                console.log(messageId + ' : ' + timestamp);
            },
        'onError':
            function(error) {
                console.log(error);
            }
    }
  );

Open WS Control Channel to ioFog

  ioFogClient.wsControlConnection(
    {
        'onNewConfigSignal':
            function() {
                console.log('New config is awaiting.');
            },
        'onEdgeResourceUpdatedSignal':
            function() {
                console.log('Agent\'s Edge Resources have been updated.');
            },
        'onError':
            function(error) {
                console.log(error);
            }
    }
  );