Class: SockJSServer

vertx/sockjs. SockJSServer

new SockJSServer()

This is an implementation of the server side part of SockJS.

You can register multiple applications with the same SockJSServer, each using different path prefixes, each application will have its own handler, and configuration.

Configuration options and their defaults are:

     - session_timeout: 5000ms
     - insert_JSESSIONID: true
     - heartbeat_period: 25000ms
     - max_bytes_streaming: 131072 (128*1024)
     - prefix: "/"
     - library_url: "http://cdn.sockjs.org/sockjs-0.3.4.min.js"
     - disabled_transports: []
   

Source:

Methods

bridge(config, inboundPermitted, outboundPermitted, bridgeConfig)

Install an app which bridges the SockJS server to the event bus
Parameters:
Name Type Description
config JSON The application configuration
inboundPermitted Array A list of JSON objects which define permitted matches for inbound (client->server) traffic
outboundPermitted Array A list of JSON objects which define permitted matches for outbound (server->client) traffic
bridgeConfig JSON A JSON object containing the configuration for the event bus bridge. Configuration options and their defaults are:
     auth_address: "vertx.basicauthmanager.authorise"
     auth_timeout: 300000ms
     ping_interval: 10000ms
     max_address_length: 200
     max_handlers_per_socket: 1000
   
Source:

installApp(config, handler) → {module:vertx/sockjs.SockJSServer}

Install a SockJS application.
Parameters:
Name Type Description
config JSON The application configuration
handler SockJSHandler The handler that will be called when SockJS sockets are created
Source:
Returns:
this
Type
module:vertx/sockjs.SockJSServer

on(evt, func)

Specify a function to call on the given event. All functions take a SockJSSocket as the first (and perhaps only) parameter. The events are:
  • socket-created - Called when a new socket is created. Use this to do things like check the origin header on the socket before accepting it. The function will be provided with a {module:vertx/sockjs.SockJSSocket}. Returning true will allow the socket to be accepted, false will cause it to be rejected.
  • pre-register - Called when a socket registers a handler on the event bus. The function will be provided with a {module:vertx/sockjs.SockJSSocket} and the address as a {string}. Return true to let the registration occur, or false otherwise.
  • post-register - Called after a socket registers a handler on the event bus. do things like check the origin header on the socket before accepting it. The function will be provided with a {module:vertx/sockjs.SockJSSocket} and the address as a {string}.
  • send-or-pub - Called when the client is sending or publishing on the socket. The function will be provided with a {module:vertx/sockjs.SockJSSocket}; a {boolean} that, if true means the client is sending on the socket, or if false the client is publishing on the socket; a {JSON} object that is the body of the message; and finally the address as a {string}. Return true to allow the message to be published/sent, false otherwise.
  • socket-closed - Called when the client socket has closed. The function will be provided with the {module:vertx/sockjs.SockJSSocket}.
  • authorize - Called on client authorization.
Parameters:
Name Type Description
evt string The name of the event
func function The function to call when the event occurs
Source: