public interface SockJSServer
SockJS enables browsers to communicate with the server using a simple WebSocket-like api for sending and receiving messages. Under the bonnet SockJS chooses to use one of several protocols depending on browser capabilities and what appears to be working across the network.
Available protocols include:
This means, it should just work irrespective of what browser is being used, and whether there are nasty things like proxies and load balancers between the client and the server.
For more detailed information on SockJS, see their website.
On the server side, you interact using instances of SockJSSocket
- this allows you to send data to the
client or receive data via the ReadSupport.dataHandler(org.vertx.java.core.Handler<M>)
.
You can register multiple applications with the same SockJSServer, each using different path prefixes, each application will have its own handler, and configuration.
Instances of this class are not thread-safe.
Modifier and Type | Method and Description |
---|---|
SockJSServer |
bridge(JsonObject sjsConfig,
JsonArray inboundPermitted,
JsonArray outboundPermitted)
Install an app which bridges the SockJS server to the event bus
|
SockJSServer |
bridge(JsonObject sjsConfig,
JsonArray inboundPermitted,
JsonArray outboundPermitted,
JsonObject bridgeConfig)
Install an app which bridges the SockJS server to the event bus
|
SockJSServer |
bridge(JsonObject sjsConfig,
JsonArray inboundPermitted,
JsonArray outboundPermitted,
long authTimeout)
Install an app which bridges the SockJS server to the event bus
|
SockJSServer |
bridge(JsonObject sjsConfig,
JsonArray inboundPermitted,
JsonArray outboundPermitted,
long authTimeout,
java.lang.String authAddress)
Install an app which bridges the SockJS server to the event bus
|
void |
close()
Close the server
|
SockJSServer |
installApp(JsonObject config,
Handler<SockJSSocket> sockHandler)
Install an application
|
SockJSServer |
setHook(EventBusBridgeHook hook)
Set a EventBusBridgeHook on the SockJS server
|
SockJSServer installApp(JsonObject config, Handler<SockJSSocket> sockHandler)
config
- The application configurationsockHandler
- A handler that will be called when new SockJS sockets are createdSockJSServer bridge(JsonObject sjsConfig, JsonArray inboundPermitted, JsonArray outboundPermitted)
sjsConfig
- The config for the appinboundPermitted
- A list of JSON objects which define permitted matches for inbound (client->server) trafficoutboundPermitted
- A list of JSON objects which define permitted matches for outbound (server->client)
trafficSockJSServer bridge(JsonObject sjsConfig, JsonArray inboundPermitted, JsonArray outboundPermitted, long authTimeout)
sjsConfig
- The config for the appinboundPermitted
- A list of JSON objects which define permitted matches for inbound (client->server) trafficoutboundPermitted
- A list of JSON objects which define permitted matches for outbound (server->client)
trafficauthTimeout
- Default time an authorisation will be cached for in the bridge (defaults to 5 minutes)SockJSServer bridge(JsonObject sjsConfig, JsonArray inboundPermitted, JsonArray outboundPermitted, long authTimeout, java.lang.String authAddress)
sjsConfig
- The config for the appinboundPermitted
- A list of JSON objects which define permitted matches for inbound (client->server) trafficoutboundPermitted
- A list of JSON objects which define permitted matches for outbound (server->client)
trafficauthTimeout
- Default time an authorisation will be cached for in the bridge (defaults to 5 minutes)authAddress
- Address of auth manager. Defaults to 'vertx.basicauthmanager.authorise'SockJSServer bridge(JsonObject sjsConfig, JsonArray inboundPermitted, JsonArray outboundPermitted, JsonObject bridgeConfig)
sjsConfig
- The config for the appinboundPermitted
- A list of JSON objects which define permitted matches for inbound (client->server) trafficoutboundPermitted
- A list of JSON objects which define permitted matches for outbound (server->client)
trafficbridgeConfig
- JSON object holding config for the EventBusBridgeSockJSServer setHook(EventBusBridgeHook hook)
hook
- The hookvoid close()