Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jollen opened this issue Jul 21, 2016 · 0 comments
Open

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

jollen opened this issue Jul 21, 2016 · 0 comments

Comments

@jollen
Copy link
Member

jollen commented Jul 21, 2016

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);
@jollen jollen changed the title How to setup a offline (local area network) IoT server with devify-server How to setup an offline IoT server with devify-server Jul 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant