home

Mobile Endpoint Security

Lookout Product Documentation

Find answers about using and optimizing Lookout products.

Streaming Events

The Lookout Mobile Risk API version 2 uses Server-Sent Events’ (SSE) protocol to push data to clients that ‘subscribe’ to the /events endpoint. The publishing model formats Lookout data in the Event stream as described by the server-sent events protocol.

Server Sent Events are useful in our case because the listener opens a unidirectional channel that does not require any client resources other than listening for events and handling them as they arrive

To subscribe to an event stream, create an EventSource object and pass it the URL of your stream:

if (!!window.EventSource) {
var source = new EventSource('stream.php');
} else {
// Result to xhr polling :(

}

If the URL passed to the EventSource constructor is an absolute URL, its origin (scheme, domain, port) must match that of the calling page.