Class: Vertx::NetClient

Inherits:
Object
  • Object
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)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


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

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

+ (Object) j_api_type



34
35
36
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_client.rb', line 34

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



37
38
39
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_client.rb', line 37

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

+ (Object) unwrap(obj)



31
32
33
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_client.rb', line 31

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

+ (Object) wrap(obj)



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

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)


72
73
74
75
76
77
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_client.rb', line 72

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

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

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

Parameters:

  • port (Fixnum) (defaults to: nil)
    the port
  • host (String) (defaults to: nil)
    the host
  • serverName (String) (defaults to: nil)
    the SNI server name

Yields:

Returns:

  • (self)

Raises:

  • (ArgumentError)


57
58
59
60
61
62
63
64
65
66
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_client.rb', line 57

def connect(port=nil,host=nil,serverName=nil)
  if port.class == Fixnum && host.class == String && block_given? && serverName == nil
    @j_del.java_method(:connect, [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,::Vertx::NetSocket) : nil) }))
    return self
  elsif port.class == Fixnum && host.class == String && serverName.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(port,host,serverName,(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(#{port},#{host},#{serverName})"
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)


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

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