Send an event notification for given characteristic and changed value to all connected clients.
If originator
is specified, the given HAPConnection will be excluded from the broadcast.
The accessory id of the updated characteristic.
The instance id of the updated characteristic.
The newly set value of the characteristic.
Optional
originator: HAPConnectionIf specified, the connection will not get an event message.
Optional
immediateDelivery: booleanThe HAP spec requires some characteristics to be delivery immediately. Namely, for the Characteristic.ButtonEvent and the Characteristic.ProgrammableSwitchEvent characteristics.
Static
destroyThis method is to be called when a given HAPConnection performs a request that should result in the disconnection of all other HAPConnection with the same HAPUsername.
The initiator MUST be in the middle of a http request were the response was not served yet. Otherwise, the initiator connection might reside in a state where it isn't disconnected and can't make any further requests.
The connection that requested to disconnect all connections of the same username.
The username for which all connections shall be closed.
EventedHTTPServer provides an HTTP-like server that supports HAP "extensions" for security and events.
Implementation
In order to implement the "custom HTTP" server required by the HAP protocol (see HAPServer.js) without completely reinventing the wheel, we create both a generic TCP socket server and a standard Node HTTP server. The TCP socket server acts as a proxy, allowing users of this class to transform data (for encryption) as necessary and passing through bytes directly to the HTTP server for processing. This way we get Node to do all the "heavy lifting" of HTTP like parsing headers and formatting responses.
Events are sent by simply waiting for current HTTP traffic to subside and then sending a custom response packet directly down the wire via the socket.
Each connection to the main TCP server gets its own internal HTTP server, so we can track ongoing requests/responses for safe event insertion.