Giter Site home page Giter Site logo

slock-js's Introduction

slock-js

the backend of the slock framework

Module-Configuration

Each Module will be created only if used within the config. The key is the filename without the ending:

 "modules" : {
	  "eth"   : { ... },  // -> will load the file modules/eth.js
	  "zwave" : { ... }   // -> will load the file modules/zwave.js
  }

For more details on the different Modules and their config, see the module-directory.

Module Creation

Each Module which is specified in the config will be created during startup. A Module will be loaded by searching within the modules-Directory and requiring this file. The module.export must be class which will be used to create the instance.

function Eth() {}
module.exports = Eth;

Events

Each Module can define any kind of event in order tocommunicate with eachother, but these are the ones created from the main-modules:

Events from the core-Module

"init"-Event

After creating all Instances the Init-Method (if existing) will be called. This is a special behavior, because it will give you an easier start-point. The object passed as argument will give you the following properties:

  • events : a EventEmitter in order to register on the event-bus
  •  <b>config</b> : the configuration as read from the config.json (or passed in)
    
  •  <b>modules</b>: a array of instances of all created Modules
    
  • oldConfig: only set if this event is triggered during a reload of the config.

the init-Method may be called more than once, if the Config-file has changed and was reloaded. In this there the oldConfig will set.

Events from the eth-Module

"watchContract"-Event

This Event will be triggered if the eth-Module starts watching for the open/close-Event from the contract. This event will be triggered for each contract.

The object passed as argument will give you the following properties:

  • config : the Configuration of the contractr as read from config. config.adr will hold the contract-adress.
  • id : the id (or key within the config)
  • web3 : the web3-object used for communicating with the eth-client.

"changeState"-Event

This Event will be triggered if a contract tells the device, that it needs to change its state.

The object passed as argument will give you the following properties:

  • open : a boolean true|false to indicate the targetState
  •  <b>id</b> : the id (or key within the config) of the device
    
  • config : the Configuration of the contract as read from config. config.adr will hold the contract-adress.

Events from the websocket-Module

"message" - Event

Whenever a Message is received for one of the contract being watched. This event will be triggered.

The Object passed as argument will give you the following properties:

  • from : the adress of sender
  •  <b>to</b> : the adress of the receiver
    
  • msg : the text or message

Events from the admin-Module

"adminMsg" - Event

sending a adminMsg-Event will cause the receiver to deliver the message to the admin.

The Object passed as argument will give you the following properties:

  • msg : the message to be delivered
  • cmd : the command-object (optional)

"adminCmd" - Event

sending a adminCmd-Event will cause the admin-Module (if loaded) to execute this cmd.

The Object passed as argument will give you the following properties:

  • name : the command to execute
  • params : the parameters to use as Array

"adminAddCmd" - Event

sending a adminCmd-Event will cause the admin-Module (if loaded) to add another command

The Object passed as argument will give you the following properties:

  • name : the command name
  • fnc : a function to be executed
  • comment : a comment to be shown if help is called

slock-js's People

Contributors

lefterisjp avatar simon-jentzsch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slock-js's Issues

bluetooth-Module

This Module should be able to receive the open/close-message per bluetooth.
And it may communicate with the bluetooth-device and reveice new configuration (like WLAN-Params)
We must find a secure way to make sure the sender is allowed to do so.

add logger

the logger must have following features:

  • redirect logging into file
  • set Loglevel [debug,warn,info,error]

module-path more flexible

loading custom-modules should be easy by adding a module-search-path in the config.

right now the module-key would be a relative-path : "../../customModules/myModule" : {}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.