Skip to content

How to setup an offline IoT server with devify-server #9

@jollen

Description

@jollen

Introduction

To add a document for teachers and instructors. This is a use case of devify-server with the purpose of education and training.

  • How to run an offline IoT server instance at teacher's laptop. The offline IoT server means that teachers and students have no need to connect to Internet cloud servers.
  • How to send data streams to teacher's laptop.
  • How to run dashboard Web app and display real-time.

nwjs

Use nwjs to start a Websocket broker server.

/// Options

process.env.PORT = 8000;
process.env.HOST = '127.0.0.1';

// -----------------------------------------------------
// Start devify server
// -----------------------------------------------------
var wsServer = require('devify-server').websocketBroker;

var onmessage = function(payload) {
    var obj = JSON.parse(payload.data);
    var paths = payload.pathname.split('/');
    var deviceId = paths[2];

    console.log('[', deviceId, ']', payload.data);
};

wsServer.start({
    onmessage: onmessage
});

/// DOM
window.addEventListener('beforeunload', function() {
    wsServer.shutdown(function() {
    });
}, false);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions