Class List Method List File List

# Class: Vertx::NetClient

Inherits:
  Object
  - Object
  - Vertx::NetClient
  show all
Includes:
  Measured
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_client.rb

## Overview

A TCP client.

Multiple connections to different servers can be made using the same instance.

This client supports a configurable number of connection attempts and a configurable delay between attempts.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (void) close
  Close the client.
- - (self) connect(param_1 = nil, param_2 = nil, param_3 = nil)
  Open a connection to a server at the specific port and host.
- - (true, false) metrics_enabled?
  Whether the metrics are enabled for this measured object.

## Class Method Details

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

Returns:

- (`Boolean`)

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

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

### + (`Object`) j_api_type

    35
    36
    37
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_client.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/net_client.rb', line 38

    def self.j_class
      Java::IoVertxCoreNet::NetClient.java_class
    end

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

    32
    33
    34
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_client.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/net_client.rb', line 29

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

## Instance Method Details

### - (`void`) close

This method returns an undefined value.

Close the client.

Any sockets which have not been closed manually will be closed here. The close is asynchronous and may not complete until some time after the method has returned.

Raises:

- (`ArgumentError`)

    91
    92
    93
    94
    95
    96
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_client.rb', line 91

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

### - (`self`) connect(remoteAddress, connectHandler) { ... } - (`self`) connect(port, host, connectHandler) { ... } - (`self`) connect(remoteAddress, serverName, connectHandler) { ... } - (`self`) connect(port, host, serverName, connectHandler) { ... }

Open a connection to a server at the specific `port` and `host`.

`host` can be a valid host name or IP address. The connect is done asynchronously and on success, a Vertx::NetSocket instance is supplied via the `connectHandler` instance

Overloads:

- - (`self`) connect(remoteAddress, connectHandler) { ... }

  Parameters:

  - remoteAddress (`::Vertx::SocketAddress`) —
    the remote address

  Yields:

- - (`self`) connect(port, host, connectHandler) { ... }

  Parameters:

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

  Yields:

- - (`self`) connect(remoteAddress, serverName, connectHandler) { ... }

  Parameters:

  - remoteAddress (`::Vertx::SocketAddress`) —
    the remote address
  - serverName (`String`) —
    the SNI server name

  Yields:

- - (`self`) connect(port, host, serverName, connectHandler) { ... }

  Parameters:

  - port (`Fixnum`) —
    the port
  - host (`String`) —
    the host
  - serverName (`String`) —
    the SNI server name

  Yields:

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_client.rb', line 70

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

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

Whether the metrics are enabled for this measured object

Returns:

- (`true`, `false`) —
  true if the metrics are enabled

Raises:

- (`ArgumentError`)

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

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