Class: VertxWeb::SockJSHandler

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/sock_js_handler.rb

Overview

A handler that allows you to handle SockJS connections from clients.

We currently support version 0.3.3 of the SockJS protocol, which can be found in this tag:

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (::VertxWeb::SockJSHandler) create(vertx = nil, options = nil)

Create a SockJS handler

Parameters:

  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vert.x instance
  • options (Hash) (defaults to: nil)
    options to configure the handler

Returns:

Raises:

  • (ArgumentError)


36
37
38
39
40
41
42
43
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/sock_js_handler.rb', line 36

def self.create(vertx=nil,options=nil)
  if vertx.class.method_defined?(:j_del) && !block_given? && options == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandlerSockjs::SockJSHandler.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxWeb::SockJSHandler)
  elsif vertx.class.method_defined?(:j_del) && options.class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWebHandlerSockjs::SockJSHandler.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtWebHandlerSockjs::SockJSHandlerOptions.java_class]).call(vertx.j_del,Java::IoVertxExtWebHandlerSockjs::SockJSHandlerOptions.new(::Vertx::Util::Utils.to_json_object(options))),::VertxWeb::SockJSHandler)
  end
  raise ArgumentError, "Invalid arguments when calling create(vertx,options)"
end

+ (void) install_test_applications(router = nil, vertx = nil)

This method returns an undefined value.

Install SockJS test applications on a router - used when running the SockJS test suite

Parameters:

  • router (::VertxWeb::Router) (defaults to: nil)
    the router to install on
  • vertx (::Vertx::Vertx) (defaults to: nil)
    the Vert.x instance

Raises:

  • (ArgumentError)


48
49
50
51
52
53
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/sock_js_handler.rb', line 48

def self.install_test_applications(router=nil,vertx=nil)
  if router.class.method_defined?(:j_del) && vertx.class.method_defined?(:j_del) && !block_given?
    return Java::IoVertxExtWebHandlerSockjs::SockJSHandler.java_method(:installTestApplications, [Java::IoVertxExtWeb::Router.java_class,Java::IoVertxCore::Vertx.java_class]).call(router.j_del,vertx.j_del)
  end
  raise ArgumentError, "Invalid arguments when calling install_test_applications(router,vertx)"
end

Instance Method Details

- (self) bridge(bridgeOptions = nil) { ... }

Like #bridge but specifying a handler that will receive bridge events.

Parameters:

  • bridgeOptions (Hash) (defaults to: nil)
    options to configure the bridge with

Yields:

  • handler to receive bridge events

Returns:

  • (self)

Raises:

  • (ArgumentError)


70
71
72
73
74
75
76
77
78
79
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/sock_js_handler.rb', line 70

def bridge(bridgeOptions=nil)
  if bridgeOptions.class == Hash && !block_given?
    @j_del.java_method(:bridge, [Java::IoVertxExtWebHandlerSockjs::BridgeOptions.java_class]).call(Java::IoVertxExtWebHandlerSockjs::BridgeOptions.new(::Vertx::Util::Utils.to_json_object(bridgeOptions)))
    return self
  elsif bridgeOptions.class == Hash && block_given?
    @j_del.java_method(:bridge, [Java::IoVertxExtWebHandlerSockjs::BridgeOptions.java_class,Java::IoVertxCore::Handler.java_class]).call(Java::IoVertxExtWebHandlerSockjs::BridgeOptions.new(::Vertx::Util::Utils.to_json_object(bridgeOptions)),(Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxWeb::BridgeEvent)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling bridge(bridgeOptions)"
end

- (void) handle(arg0 = nil)

This method returns an undefined value.

Parameters:

Raises:

  • (ArgumentError)


26
27
28
29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/sock_js_handler.rb', line 26

def handle(arg0=nil)
  if arg0.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:handle, [Java::IoVertxExtWeb::RoutingContext.java_class]).call(arg0.j_del)
  end
  raise ArgumentError, "Invalid arguments when calling handle(arg0)"
end

- (self) socket_handler { ... }

Set a SockJS socket handler. This handler will be called with a SockJS socket whenever a SockJS connection is made from a client

Yields:

  • the handler

Returns:

  • (self)

Raises:

  • (ArgumentError)


58
59
60
61
62
63
64
# File '/Users/julien/java/vertx-aggregator/modules/vertx-web/src/main/resources/vertx-web/sock_js_handler.rb', line 58

def socket_handler
  if block_given?
    @j_del.java_method(:socketHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(::Vertx::Util::Utils.safe_create(event,::VertxWeb::SockJSSocket)) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling socket_handler()"
end