This is an implementation of the server side part of SockJS

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:

  • WebSockets
  • xhr-polling
  • xhr-streaming
  • json-polling
  • event-source
  • html-file

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 SockJSSocket.readStream ReadStream.dataHandler().

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.

no subtypes hierarchy

Initializer
SockJSServer(SockJSServer delegate)
Inherited Attributes
Attributes inherited from: Object
hash, string
Methods
bridgeshared SockJSServer bridge(Object sjsConfig, Array inboundPermitted, Array outboundPermitted, Object? bridgeConfig = null)

Install an app which bridges the SockJS server to the event bus

Parameters:
  • sjsConfig

    The config for the app

  • inboundPermitted

    A list of JSON objects which define permitted matches for inbound (client->server) traffic

  • outboundPermitted

    A list of JSON objects which define permitted matches for outbound (server->client) traffic

  • bridgeConfig = null

    JSON object holding config for the EventBusBridge

closeshared void close()

Close the server

installAppshared SockJSServer installApp(Object config, void sockHandler(SockJSSocket socket))

Install an application

Parameters:
  • config

    The config for the app

  • sockHandler

    A handler that will be called when new SockJS sockets are created

setHookshared SockJSServer setHook(EventBusBridgeHook hook)

Set a EventBusBridgeHook on the SockJS server

Parameters:
  • hook

    The hook

Inherited Methods
Methods inherited from: Object
equals