Difference between revisions of "EventStream Interface"
(Created page with "=Overview= Hubitat allows for opening and maintaining a connection to an event stream endpoint from the hub. All code needs to be contained in a driver, there is no option to...") |
|||
Line 1: | Line 1: | ||
=Overview= | =Overview= | ||
Hubitat allows for opening and maintaining a connection to an event stream endpoint from the hub. All code needs to be contained in a driver, there is no option to open an event stream connection from an app. Hubitat provides methods to connect and disconnect to the endpoint, in addition it is required to create a method in the driver that accepts incoming messages (parse) and another method that will be called with any status updates for the endpoint (eventStreamStatus). | Hubitat allows for opening and maintaining a connection to an event stream endpoint from the hub. All code needs to be contained in a driver, there is no option to open an event stream connection from an app. Hubitat provides methods to connect and disconnect to the endpoint, in addition it is required to create a method in the driver that accepts incoming messages (parse) and another method that will be called with any status updates for the endpoint (eventStreamStatus). | ||
+ | |||
+ | =Methods= | ||
+ | |||
+ | ==Hubitat Provided Methods== | ||
+ | |||
+ | ===<code>connect</code>=== | ||
+ | :;Signature | ||
+ | :: <code>void connect(String url)</code> | ||
+ | :: <code>void connect(String url, [options (name/value pairs)])</code> | ||
+ | |||
+ | :;Parameters | ||
+ | :: url - The url to connect to. | ||
+ | :: options - Optional parameters to configure the web socket connection. Possible values: | ||
+ | :::''pingInterval'' - The number of seconds to send a ping message. Defaults to 0 (disabled). | ||
+ | :::''headers'' - A Map of key/value pairs to send as header values when connecting to the web socket server. | ||
+ | |||
+ | ===<code>close</code>=== | ||
+ | |||
+ | :;Signature | ||
+ | :: <code>void close()</code> | ||
+ | |||
+ | :;Examples | ||
+ | |||
+ | // Close connection | ||
+ | interfaces.eventStream.close() |
Revision as of 22:32, 21 August 2019
Overview
Hubitat allows for opening and maintaining a connection to an event stream endpoint from the hub. All code needs to be contained in a driver, there is no option to open an event stream connection from an app. Hubitat provides methods to connect and disconnect to the endpoint, in addition it is required to create a method in the driver that accepts incoming messages (parse) and another method that will be called with any status updates for the endpoint (eventStreamStatus).
Methods
Hubitat Provided Methods
connect
- Signature
void connect(String url)
void connect(String url, [options (name/value pairs)])
- Parameters
- url - The url to connect to.
- options - Optional parameters to configure the web socket connection. Possible values:
- pingInterval - The number of seconds to send a ping message. Defaults to 0 (disabled).
- headers - A Map of key/value pairs to send as header values when connecting to the web socket server.
close
- Signature
void close()
- Examples
// Close connection interfaces.eventStream.close()