Class: VertxWeb::SockJSHandler

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-stack/stack-docs/target/rb/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:

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


26
27
28
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/sock_js_handler.rb', line 26

def @@j_api_type.accept?(obj)
  obj.class == SockJSHandler
end

+ (::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)


53
54
55
56
57
58
59
60
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/sock_js_handler.rb', line 53

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:

Raises:

  • (ArgumentError)


65
66
67
68
69
70
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/sock_js_handler.rb', line 65

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

+ (Object) j_api_type



35
36
37
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/sock_js_handler.rb', line 35

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



38
39
40
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/sock_js_handler.rb', line 38

def self.j_class
  Java::IoVertxExtWebHandlerSockjs::SockJSHandler.java_class
end

+ (Object) unwrap(obj)



32
33
34
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/sock_js_handler.rb', line 32

def @@j_api_type.unwrap(obj)
  obj.j_del
end

+ (Object) wrap(obj)



29
30
31
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/sock_js_handler.rb', line 29

def @@j_api_type.wrap(obj)
  SockJSHandler.new(obj)
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)


87
88
89
90
91
92
93
94
95
96
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/sock_js_handler.rb', line 87

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)


43
44
45
46
47
48
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/sock_js_handler.rb', line 43

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)


75
76
77
78
79
80
81
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/sock_js_handler.rb', line 75

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