All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.jsync.sockjs.SockJSServer Maven / Gradle / Ivy

There is a newer version: 1.10.13
Show newest version
/*
 * Copyright (c) 2011-2013 The original author or authors
 * ------------------------------------------------------
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and Apache License v2.0 which accompanies this distribution.
 *
 *     The Eclipse Public License is available at
 *     http://www.eclipse.org/legal/epl-v10.html
 *
 *     The Apache License v2.0 is available at
 *     http://www.opensource.org/licenses/apache2.0.php
 *
 * You may elect to redistribute this code under either of these licenses.
 */

package io.jsync.sockjs;

import io.jsync.Handler;
import io.jsync.json.JsonArray;
import io.jsync.json.JsonObject;

/**
 * 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 {@link SockJSSocket} - this allows you to send data to the * client or receive data via the {@link SockJSSocket#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.

* * @author Tim Fox */ public interface SockJSServer { /** * Install an application * * @param config The application configuration * @param sockHandler A handler that will be called when new SockJS sockets are created */ SockJSServer installApp(JsonObject config, Handler sockHandler); /** * Install an app which bridges the SockJS server to the event bus * * @param sjsConfig The config for the app * @param inboundPermitted A list of JSON objects which define permitted matches for inbound (client->server) traffic * @param outboundPermitted A list of JSON objects which define permitted matches for outbound (server->client) * traffic */ SockJSServer bridge(JsonObject sjsConfig, JsonArray inboundPermitted, JsonArray outboundPermitted); /** * Install an app which bridges the SockJS server to the event bus * * @param sjsConfig The config for the app * @param inboundPermitted A list of JSON objects which define permitted matches for inbound (client->server) traffic * @param outboundPermitted A list of JSON objects which define permitted matches for outbound (server->client) * traffic * @param authTimeout 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); /** * Install an app which bridges the SockJS server to the event bus * * @param sjsConfig The config for the app * @param inboundPermitted A list of JSON objects which define permitted matches for inbound (client->server) traffic * @param outboundPermitted A list of JSON objects which define permitted matches for outbound (server->client) * traffic * @param authTimeout Default time an authorisation will be cached for in the bridge (defaults to 5 minutes) * @param authAddress Address of auth manager. Defaults to 'async.basicauthmanager.authorise' */ SockJSServer bridge(JsonObject sjsConfig, JsonArray inboundPermitted, JsonArray outboundPermitted, long authTimeout, String authAddress); /** * Install an app which bridges the SockJS server to the event bus * * @param sjsConfig The config for the app * @param inboundPermitted A list of JSON objects which define permitted matches for inbound (client->server) traffic * @param outboundPermitted A list of JSON objects which define permitted matches for outbound (server->client) * traffic * @param bridgeConfig JSON object holding config for the EventBusBridge */ SockJSServer bridge(JsonObject sjsConfig, JsonArray inboundPermitted, JsonArray outboundPermitted, JsonObject bridgeConfig); /** * Set a EventBusBridgeHook on the SockJS server * * @param hook The hook */ SockJSServer setHook(EventBusBridgeHook hook); /** * Close the server */ void close(); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy