Class List Method List File List

# Class: VertxStomp::StompClient

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

## Overview

Defines a STOMP client.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::VertxStomp::StompClient) create(vertx = nil, options = nil)
  Creates a StompClient using the default implementation.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (void) close
  Closes the client.
- - (true, false) closed?
  Whether or not the client is connected to the server.
- - (self) connect(param_1 = nil, param_2 = nil, param_3 = nil)
  Connects to the server.
- - (self) error_frame_handler { ... }
  A general error frame handler.
- - (self) exception_handler { ... }
  Sets an exception handler notified for TCP-level errors.
- - (Hash) options
  The client's options.
- - (self) received_frame_handler { ... }
  Configures a received handler that gets notified when a STOMP frame is received by the client.
- - (::Vertx::Vertx) vertx
  The vert.x instance used by the client.
- - (self) writing_frame_handler { ... }
  Configures a writing handler that gets notified when a STOMP frame is written on the wire.

## Class Method Details

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    20
    21
    22
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_client.rb', line 20

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

### + (`::VertxStomp::StompClient`) create(vertx = nil, options = nil)

Creates a VertxStomp::StompClient using the default implementation.

Parameters:

- vertx (`::Vertx::Vertx`) (defaults to: `nil`) —
  the vert.x instance to use
- options (`Hash`) (defaults to: `nil`) —
  the options

Returns:

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

Raises:

- (`ArgumentError`)

    39
    40
    41
    42
    43
    44
    45
    46
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_client.rb', line 39

    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::IoVertxExtStomp::StompClient.java_method(:create, [Java::IoVertxCore::Vertx.java_class]).call(vertx.j_del),::VertxStomp::StompClient)
      elsif vertx.class.method_defined?(:j_del) && options.class == Hash && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtStomp::StompClient.java_method(:create, [Java::IoVertxCore::Vertx.java_class,Java::IoVertxExtStomp::StompClientOptions.java_class]).call(vertx.j_del,Java::IoVertxExtStomp::StompClientOptions.new(::Vertx::Util::Utils.to_json_object(options))),::VertxStomp::StompClient)
      end
      raise ArgumentError, "Invalid arguments when calling create(#{vertx},#{options})"
    end

### + (`Object`) j_api_type

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

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

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

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

### + (`Object`) unwrap(obj)

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

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

### + (`Object`) wrap(obj)

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

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

## Instance Method Details

### - (`void`) close

This method returns an undefined value.

Closes the client.

Raises:

- (`ArgumentError`)

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

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

### - (`true`, `false`) closed?

Returns whether or not the client is connected to the server.

Returns:

- (`true`, `false`) —
  whether or not the client is connected to the server.

Raises:

- (`ArgumentError`)

    152
    153
    154
    155
    156
    157
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_client.rb', line 152

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

### - (`self`) connect(resultHandler) { ... } - (`self`) connect(net, resultHandler) { ... } - (`self`) connect(port, host, resultHandler) { ... } - (`self`) connect(port, host, net, resultHandler) { ... }

Connects to the server.

Overloads:

- - (`self`) connect(resultHandler) { ... }

  Yields:

  - handler called with the connection result. A failure will be sent to the handler if a TCP level issue happen before the `CONNECTED` frame is received. Afterwards, the #exception_handler is called.
- - (`self`) connect(net, resultHandler) { ... }

  Parameters:

  - net (`::Vertx::NetClient`) —
    the NET client to use

  Yields:

  - handler called with the connection result
- - (`self`) connect(port, host, resultHandler) { ... }

  Parameters:

  - port (`Fixnum`) —
    the server port
  - host (`String`) —
    the server host

  Yields:

  - handler called with the connection result
- - (`self`) connect(port, host, net, resultHandler) { ... }

  Parameters:

  - port (`Fixnum`) —
    the server port
  - host (`String`) —
    the server host
  - net (`::Vertx::NetClient`) —
    the NET client to use

  Yields:

  - handler called with the connection result

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_client.rb', line 63

    def connect(param_1=nil,param_2=nil,param_3=nil)
      if block_given? && param_1 == nil && param_2 == nil && param_3 == nil
        @j_del.java_method(:connect, [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::StompClientConnection) : nil) }))
        return self
      elsif param_1.class.method_defined?(:j_del) && block_given? && param_2 == nil && param_3 == nil
        @j_del.java_method(:connect, [Java::IoVertxCoreNet::NetClient.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxStomp::StompClientConnection) : nil) }))
        return self
      elsif param_1.class == Fixnum && param_2.class == String && block_given? && param_3 == nil
        @j_del.java_method(:connect, [Java::int.java_class,Java::java.lang.String.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,param_2,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxStomp::StompClientConnection) : nil) }))
        return self
      elsif param_1.class == Fixnum && param_2.class == String && param_3.class.method_defined?(:j_del) && block_given?
        @j_del.java_method(:connect, [Java::int.java_class,Java::java.lang.String.java_class,Java::IoVertxCoreNet::NetClient.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,param_2,param_3.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::VertxStomp::StompClientConnection) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling connect(#{param_1},#{param_2},#{param_3})"
    end

### - (`self`) error_frame_handler { ... }

A general error frame handler. It can be used to catch `ERROR` frame emitted during the connection process (wrong authentication). This error handler will be pass to all VertxStomp::StompClientConnection created from this client. Obviously, the client can override it when the connection is established.

Yields:

- the handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    112
    113
    114
    115
    116
    117
    118
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_client.rb', line 112

    def error_frame_handler
      if block_given?
        @j_del.java_method(:errorFrameHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event != nil ? JSON.parse(event.toJson.encode) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling error_frame_handler()"
    end

### - (`self`) exception_handler { ... }

Sets an exception handler notified for TCP-level errors.

Yields:

- the handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    122
    123
    124
    125
    126
    127
    128
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_client.rb', line 122

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

### - (`Hash`) options

Returns the client's options.

Returns:

- (`Hash`) —
  the client's options.

Raises:

- (`ArgumentError`)

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

    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

### - (`self`) received_frame_handler { ... }

Configures a received handler that gets notified when a STOMP frame is received by the client. This handler can be used for logging, debugging or ad-hoc behavior. The frame can still be modified at the time.

When a connection is created, the handler is used as VertxStomp::StompClientConnection#received_frame_handler.

Yields:

- the handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    86
    87
    88
    89
    90
    91
    92
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_client.rb', line 86

    def received_frame_handler
      if block_given?
        @j_del.java_method(:receivedFrameHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event != nil ? JSON.parse(event.toJson.encode) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling received_frame_handler()"
    end

### - (`::Vertx::Vertx`) vertx

Returns the vert.x instance used by the client.

Returns:

- (`::Vertx::Vertx`) —
  the vert.x instance used by the client.

Raises:

- (`ArgumentError`)

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

    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

### - (`self`) writing_frame_handler { ... }

Configures a writing handler that gets notified when a STOMP frame is written on the wire. This handler can be used for logging, debugging or ad-hoc behavior. The frame can still be modified at the time.

When a connection is created, the handler is used as VertxStomp::StompClientConnection#writing_frame_handler.

Yields:

- the handler

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    100
    101
    102
    103
    104
    105
    106
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-stomp/stomp_client.rb', line 100

    def writing_frame_handler
      if block_given?
        @j_del.java_method(:writingFrameHandler, [Java::IoVertxCore::Handler.java_class]).call((Proc.new { |event| yield(event != nil ? JSON.parse(event.toJson.encode) : nil) }))
        return self
      end
      raise ArgumentError, "Invalid arguments when calling writing_frame_handler()"
    end