Class: Vertx::SockJSServer
- Inherits:
-
Object
- Object
- Vertx::SockJSServer
- Defined in:
- src/main/ruby_scripts/core/sock_js.rb
Overview
This is an implementation of the server side part of "https://github.com/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 apppears 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 ReadStream#data_handler.
You can register multiple applications with the same SockJSServer, each using different path prefixes, each
application will have its own handler, and configuration is described in a Hash.
Instance Method Summary (collapse)
- - (Object) bridge(config, inbound_permitted, outbound_permitted, auth_timeout = 5*60*1000, auth_address = nil)
-
- (SockJSServer) initialize(http_server)
constructor
Create a new SockJSServer.
-
- (Object) install_app(config, proc = nil, &hndlr)
Install an application.
Constructor Details
- (SockJSServer) initialize(http_server)
Create a new SockJSServer
50 51 52 |
# File 'src/main/ruby_scripts/core/sock_js.rb', line 50 def initialize(http_server) @j_server = org.vertx.java.deploy.impl.VertxLocator.vertx.createSockJSServer(http_server._to_java_server) end |
Instance Method Details
- (Object) bridge(config, inbound_permitted, outbound_permitted, auth_timeout = 5*60*1000, auth_address = nil)
66 67 68 69 70 71 |
# File 'src/main/ruby_scripts/core/sock_js.rb', line 66 def bridge(config, inbound_permitted, outbound_permitted, auth_timeout = 5 * 60 * 1000, auth_address = nil) j_inbound_permitted = org.vertx.java.core.json.JsonArray.new(inbound_permitted) j_outbound_permitted = org.vertx.java.core.json.JsonArray.new(outbound_permitted) @j_server.bridge(org.vertx.java.core.json.JsonObject.new(config), j_inbound_permitted, j_outbound_permitted, auth_timeout, auth_address) end |
- (Object) install_app(config, proc = nil, &hndlr)
Install an application
58 59 60 61 62 63 64 |
# File 'src/main/ruby_scripts/core/sock_js.rb', line 58 def install_app(config, proc = nil, &hndlr) hndlr = proc if proc j_config = org.vertx.java.core.json.JsonObject.new(config) @j_server.installApp(j_config) { |j_sock| hndlr.call(SockJSSocket.new(j_sock)) } end |