-
Notifications
You must be signed in to change notification settings - Fork 0
Client Usage
Rather just see examples? Go straight to the Client Examples page
Connecting is just the normal WebSocket connection protocol. By default, the server listens on TCP port 8887.
After the connection is established, the server expects to receive one, and only one, message, which contains a JSON object called the config. See the config details below. Example configs here.
After the config is accepted, all the client does is receive data, which will be sent based on the batchSize and maxSecs config values. The response object is also described below.
The config must be a valid JSON object, and must conform to the specification in the table below. Once a valid config is accepted by the server on a connection, it cannot be change. Any further configs sent will be ignored.
| key | type | required | default | semantics |
|---|---|---|---|---|
| ip | string | true | Multicast UDP IP adddress to listen on for LWES events. | |
| port | int | true | TCP port to listen on for LWES events. | |
| batchSize | int | false | 100 | The number of LWES events to send in each response. |
| maxSecs | int | false | 60 | Max number of seconds to wait before sending a response. |
| requests | JSON object | true | LWES event names and attributes to return. | |
| filters | JSON object | false | [] | Filters which each event must match. |
The request object is a map from strings to arrays of strings. The keys are LWES event names, and value array contains names of attributes. For example:
{'Search': ['term','lat','lon'], 'Ad': ['text'] }
This signifies that all LWES events on the channel with names "Search" or "Ad" should be returned, but with only the attributes listed for each name. For example, there may be 50 different attributes in any give "Search" event, but only the "term", "lat" and "lon" attributes are returned.
Names and attributes must exactly match their counterparts in the LWES event, with two exceptions.The name in the config can be the empty string (""), which represents all names. Similarly, the attribution array can be an empty array ([]), which represents all attributes.
The filters object is an array of filter objects. Each filter object must contain three attributes: 'name', 'attribute' and 'value'. "name" and "value" are (Java) regular expressions. "attribute" is just a string. Here's an example of the filters value that contains two filter objects:
'filters' : [{'name' : '.*', 'attribute' : 'count', 'value' : '^.*9$'},
{'name' : '.*', 'attribute' : 'eid', 'value' : '.*'}
],
The first filter restricts to only events which have a 'count' attribute value ending in the digit '9'. The second filter restricts to those containing an 'eid' attribute. Each event must pass all filters, so an event containing count: 29 but no 'eid' attribute would be filtered out.