Minimal Maven scaffold for trying out web applications as web socket clients. Based on the Maven Standard Directory Layout
Includes embedded Maven Jetty plugin (hot reload on per default).
- Clone this repo
mvn clean install
mvn jetty:run
The console log should look something like this.
This is a plain JEE7 Web Application. At startup it creates a websocket connection using a ServletContextListener. It passes the class WebSocketClient as ClientEndpoint. The ClientEndpoint handles all incoming events.
- As the WAR deploys, a ServletContextListener will be created and invoked
- The context listener looks for a system 'env' variable and reads the corresponding properties file ('prod' is the default env) from classpath
- Once the file is read and the container is starting, the listener will connect and send a connection message to the server with some parameters (see below)
- The event handler is registered by the context listener on the websocket
Not yet fully implemented.
Once a connection is established, the client will send a message to the server.
The message contains the following parameters
id
: Just a client id, to have somethig to refer toapiKey
: A valid API key. Without this, the client will be ignored by the servermsgFilter
: key-value pair used to filter messages the client is interested in (no filter = all events)channel
: The channel to listen to. Curently only one channel is available. 'clickStream', where all click events are propagated
Currently not supported.
Will most likely be an event sent by the client requesting replay from a certain timestamp. There will be a special temporary channel for this where the client is the only subscriber. (Suggesting -. Ex: clickStream-id:12345678)
- The start class WebSocketAPIConnector
- The event handler: WebSocketClient
- The properties file appConf_prod.properties
Some startng points