EventedHTTPServer provides an HTTP-like server that supports HAP "extensions" for security and events.
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.
Send an event notification for given characteristic and changed value to all connected clients.
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.
If specified, the connection will not get an event message.
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.