nioc / jeedom-websocket

Jeedom plugin to provide a client-server communication over websocket protocol
GNU General Public License v2.0
2 stars 0 forks source link
jeedom jeedom-plugin websocket websocket-server

Screenshot desktop Jeedom Websocket

license: GPLv2 GitHub release

Jeedom plugin to provide a reliable low latency bidirectional client-server communication over websocket protocol.

Events are pushed to clients avoiding long polling (Ajax request) overhead.

Reduce server load by sharing the Jeedom query and broadcast result to multiples clients.

Installation & configuration

Use

To get Jeedom events, client:

  1. connect to websocket endpoint,
  2. send user API key as soon as onopen event occurs,
  3. do your useful stuffs with Jeedom events.

JavaScript example:

//1. connect
const websocket = new WebSocket('ws://10.0.0.42/myawesomesocket')

//2. send user credentials
websocket.onopen = (e) => {
  const authMsg = JSON.stringify({ apiKey: 'userApiKey' })
  websocket.send(authMsg)
}

//3. Handle events
websocket.onmessage = (e) => {
  //do stuff with Jeedom events (e.data.result)
}
websocket.onerror = (e) => {
  //handle error
}
websocket.onclose = (e) => {
  //handle connection closed
}

Credits

See also the list of contributors to this project.

This project is powered by the following components: