Class: VertxStomp::StompServer

Inherits:
Object
  • Object
show all
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb

Overview

Defines a STOMP server. STOMP servers delegates to a StompServerHandler that let customize the behavior of the server. By default, it uses a handler compliant with the STOMP specification, but let you change anything.

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


23
24
25
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 23

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

+ (::VertxStomp::StompServer) create(vertx) + (::VertxStomp::StompServer) create(vertx, options) + (::VertxStomp::StompServer) create(vertx, netServer) + (::VertxStomp::StompServer) create(vertx, net, options)

Creates a VertxStomp::StompServer based on the default Stomp Server implementation.

Overloads:

Returns:

Raises:

  • (ArgumentError)


52
53
54
55
56
57
58
59
60
61
62
63
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 52

def self.create(param_1=nil,param_2=nil,param_3=nil)
  if param_1.class.method_defined?(:j_del) && !block_given? && param_2 == nil && param_3 == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtStomp::StompServer.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(param_1.j_del),::VertxStomp::StompServer)
  elsif param_1.class.method_defined?(:j_del) && param_2.class == Hash && !block_given? && param_3 == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtStomp::StompServer.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtStomp::StompServerOptions.java_class]).call(param_1.j_del,Java::IoVertxExtStomp::StompServerOptions.new(::Vertx::Util::Utils.to_json_object(param_2))),::VertxStomp::StompServer)
  elsif param_1.class.method_defined?(:j_del) && param_2.class.method_defined?(:j_del) && !block_given? && param_3 == nil
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtStomp::StompServer.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreNet::NetServer.java_class]).call(param_1.j_del,param_2.j_del),::VertxStomp::StompServer)
  elsif param_1.class.method_defined?(:j_del) && param_2.class.method_defined?(:j_del) && param_3.class == Hash && !block_given?
    return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtStomp::StompServer.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxCoreNet::NetServer.java_class,Java::IoVertxExtStomp::StompServerOptions.java_class]).call(param_1.j_del,param_2.j_del,Java::IoVertxExtStomp::StompServerOptions.new(::Vertx::Util::Utils.to_json_object(param_3))),::VertxStomp::StompServer)
  end
  raise ArgumentError, "Invalid arguments when calling create(#{param_1},#{param_2},#{param_3})"
end

+ (Object) j_api_type



32
33
34
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 32

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



35
36
37
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 35

def self.j_class
  Java::IoVertxExtStomp::StompServer.java_class
end

+ (Object) unwrap(obj)



29
30
31
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 29

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

+ (Object) wrap(obj)



26
27
28
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 26

def @@j_api_type.wrap(obj)
  StompServer.new(obj)
end

Instance Method Details

- (Fixnum) actual_port

Gets the port on which the server is listening.

This is useful if you bound the server specifying 0 as port number signifying an ephemeral port.

Returns:

  • (Fixnum)
    the port

Raises:

  • (ArgumentError)


125
126
127
128
129
130
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 125

def actual_port
  if !block_given?
    return @j_del.java_method(:actualPort, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling actual_port()"
end

- (void) close { ... }

This method returns an undefined value.

Closes the server.

Yields:

  • handler called once the server has been stopped

Raises:

  • (ArgumentError)


105
106
107
108
109
110
111
112
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 105

def close
  if !block_given?
    return @j_del.java_method(:close, []).call()
  elsif block_given?
    return @j_del.java_method(:close, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))
  end
  raise ArgumentError, "Invalid arguments when calling close()"
end

- (self) handler(handler = nil)

Configures the VertxStomp::StompServerHandler. You must calls this method before calling the #listen method.

Parameters:

Returns:

  • (self)

Raises:

  • (ArgumentError)


67
68
69
70
71
72
73
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 67

def handler(handler=nil)
  if handler.class.method_defined?(:j_del) && !block_given?
    @j_del.java_method(:handler, [Java::IoVertxExtStomp::StompServerHandler.java_class]).call(handler.j_del)
    return self
  end
  raise ArgumentError, "Invalid arguments when calling handler(#{handler})"
end

- (self) listen(port = nil, host = nil) { ... }

Connects the STOMP server to the given port / interface. Once the socket it bounds calls the given handler with the result. The result may be a failure if the socket is already used.

Parameters:

  • port (Fixnum) (defaults to: nil)
    the port
  • host (String) (defaults to: nil)
    the host / interface

Yields:

  • the handler to call with the result

Returns:

  • (self)

Raises:

  • (ArgumentError)


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 80

def listen(port=nil,host=nil)
  if !block_given? && port == nil && host == nil
    @j_del.java_method(:listen, []).call()
    return self
  elsif port.class == Fixnum && !block_given? && host == nil
    @j_del.java_method(:listen, [Java::int.java_class]).call(port)
    return self
  elsif block_given? && port == nil && host == nil
    @j_del.java_method(:listen, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxStomp::StompServer) : nil) }))
    return self
  elsif port.class == Fixnum && host.class == String && !block_given?
    @j_del.java_method(:listen, [Java::int.java_class,Java::java.lang.String.java_class]).call(port,host)
    return self
  elsif port.class == Fixnum && block_given? && host == nil
    @j_del.java_method(:listen, [Java::int.java_class,Java::IoVertxCore::Handler.java_class]).call(port,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxStomp::StompServer) : nil) }))
    return self
  elsif port.class == Fixnum && host.class == String && block_given?
    @j_del.java_method(:listen, [Java::int.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(port,host,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxStomp::StompServer) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling listen(#{port},#{host})"
end

- (true, false) listening?

Checks whether or not the server is listening.

Returns:

  • (true, false)
    true if the server is listening, false otherwise

Raises:

  • (ArgumentError)


115
116
117
118
119
120
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 115

def listening?
  if !block_given?
    return @j_del.java_method(:isListening, []).call()
  end
  raise ArgumentError, "Invalid arguments when calling listening?()"
end

- (Hash) options

Returns the server options

Returns:

  • (Hash)
    the server options

Raises:

  • (ArgumentError)


132
133
134
135
136
137
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 132

def options
  if !block_given?
    return @j_del.java_method(:options, []).call() != nil ? JSON.parse(@j_del.java_method(:options, []).call().toJson.encode) : nil
  end
  raise ArgumentError, "Invalid arguments when calling options()"
end

- (::VertxStomp::StompServerHandler) stomp_handler

Returns the VertxStomp::StompServerHandler used by this server.

Returns:

Raises:

  • (ArgumentError)


146
147
148
149
150
151
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 146

def stomp_handler
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:stompHandler, []).call(),::VertxStomp::StompServerHandler)
  end
  raise ArgumentError, "Invalid arguments when calling stomp_handler()"
end

- (::Vertx::Vertx) vertx

Returns the instance of vert.x used by the server.

Returns:

Raises:

  • (ArgumentError)


139
140
141
142
143
144
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 139

def vertx
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:vertx, []).call(),::Vertx::Vertx)
  end
  raise ArgumentError, "Invalid arguments when calling vertx()"
end

- (Proc) web_socket_handler

Gets the able to manage web socket connections. If the web socket bridge is disabled, it returns null.

Returns:

Raises:

  • (ArgumentError)


155
156
157
158
159
160
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 155

def web_socket_handler
  if !block_given?
    return ::Vertx::Util::Utils.to_handler_proc(@j_del.java_method(:webSocketHandler, []).call()) { |val| val.j_del }
  end
  raise ArgumentError, "Invalid arguments when calling web_socket_handler()"
end

- (self) writing_frame_handler { ... }

Configures the handler that is invoked every time a frame is going to be written to the "wire". It lets you log the frames, but also adapt the frame if needed.

Yields:

  • the handler, must not be null

Returns:

  • (self)

Raises:

  • (ArgumentError)


165
166
167
168
169
170
171
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_server.rb', line 165

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