Class List Method List File List

# Class: VertxStomp::StompServer

Inherits:
  Object
  - Object
  - VertxStomp::StompServer
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-stomp/src/main/resources/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.

## Class Method Summary (collapse)

- + (::VertxStomp::StompServer) create(param_1 = nil, param_2 = nil, param_3 = nil)
  Creates a StompServer based on the default Stomp Server implementation.

## Instance Method Summary (collapse)

- - (Fixnum) actual_port
  Gets the port on which the server is listening.
- - (void) close { ... }
  Closes the server.
- - (self) handler(handler = nil)
  Configures the StompServerHandler.
- - (self) listen(port = nil, host = nil) { ... }
  Connects the STOMP server to the given port / interface.
- - (true, false) listening?
  Checks whether or not the server is listening.
- - (Hash) options
  @return the server options.
- - (::VertxStomp::StompServerHandler) stomp_handler
  @return the StompServerHandler used by this server.
- - (::Vertx::Vertx) vertx
  @return the instance of vert.x used by the server.

## Class Method Details

### + (`::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:

- + (`::VertxStomp::StompServer`) create(vertx)

  Parameters:

  - vertx (`::Vertx::Vertx`) —
    the vert.x instance to use
- + (`::VertxStomp::StompServer`) create(vertx, options)

  Parameters:

  - vertx (`::Vertx::Vertx`) —
    the vert.x instance to use
  - options (`Hash`) —
    the server options
- + (`::VertxStomp::StompServer`) create(vertx, netServer)

  Parameters:

  - vertx (`::Vertx::Vertx`) —
    the vert.x instance to use
  - netServer (`::Vertx::NetServer`) —
    the Net server used by the STOMP server
- + (`::VertxStomp::StompServer`) create(vertx, net, options)

  Parameters:

  - vertx (`::Vertx::Vertx`) —
    the vert.x instance to use
  - net (`::Vertx::NetServer`) —
    the Net server used by the STOMP server
  - options (`Hash`) —
    the server options

Returns:

- (`::VertxStomp::StompServer`) —
  the created VertxStomp::StompServer

Raises:

- (`ArgumentError`)

    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-stomp/src/main/resources/vertx-stomp/stomp_server.rb', line 34

    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

## 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`)

    107
    108
    109
    110
    111
    112
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-stomp/src/main/resources/vertx-stomp/stomp_server.rb', line 107

    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`)

    87
    88
    89
    90
    91
    92
    93
    94
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-stomp/src/main/resources/vertx-stomp/stomp_server.rb', line 87

    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:

- handler (`::VertxStomp::StompServerHandler`) (defaults to: `nil`) —
  the handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    49
    50
    51
    52
    53
    54
    55
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-stomp/src/main/resources/vertx-stomp/stomp_server.rb', line 49

    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`)

    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-stomp/src/main/resources/vertx-stomp/stomp_server.rb', line 62

    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`)

    97
    98
    99
    100
    101
    102
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-stomp/src/main/resources/vertx-stomp/stomp_server.rb', line 97

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

### - (`Hash`) options

@return the server options

Returns:

- (`Hash`)

Raises:

- (`ArgumentError`)

    115
    116
    117
    118
    119
    120
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-stomp/src/main/resources/vertx-stomp/stomp_server.rb', line 115

    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

@return the VertxStomp::StompServerHandler used by this server.

Returns:

- (`::VertxStomp::StompServerHandler`)

Raises:

- (`ArgumentError`)

    131
    132
    133
    134
    135
    136
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-stomp/src/main/resources/vertx-stomp/stomp_server.rb', line 131

    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

@return the instance of vert.x used by the server.

Returns:

- (`::Vertx::Vertx`)

Raises:

- (`ArgumentError`)

    123
    124
    125
    126
    127
    128
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-stomp/src/main/resources/vertx-stomp/stomp_server.rb', line 123

    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