Class: Vertx::NetClient

Inherits:
Object
  • Object
show all
Includes:
ClientSSLSupport, SSLSupport, TCPSupport
Defined in:
src/main/api_shim/core/net.rb

Overview

NetClient is an asynchronous factory for TCP or SSL connections. Multiple connections to different servers can be made using the same instance.

Author:

Instance Method Summary (collapse)

Methods included from SSLSupport

#key_store_password, #key_store_password=, #key_store_path, #key_store_path=, #ssl, #ssl=, #trust_store_password, #trust_store_password=, #trust_store_path, #trust_store_path=

Methods included from ClientSSLSupport

#trust_all, #trust_all=

Methods included from TCPSupport

#receive_buffer_size=, #reuse_address, #reuse_address=, #send_buffer_size, #send_buffer_size=, #send_receive_size, #so_linger, #so_linger=, #tcp_keep_alive, #tcp_keep_alive=, #traffic_class, #traffic_class=, #use_pooled_buffers, #use_pooled_buffers=

Constructor Details

- (NetClient) initialize

Create a new NetClient


86
87
88
# File 'src/main/api_shim/core/net.rb', line 86

def initialize
  @j_del = org.vertx.java.platform.impl.JRubyVerticleFactory.vertx.createNetClient
end

Instance Method Details

- (Object) close

Close the NetClient. Any open connections will be closed.


152
153
154
# File 'src/main/api_shim/core/net.rb', line 152

def close
  @j_del.close
end

- (NetClient) connect(port, host = "localhost", &hndlr)

Attempt to open a connection to a server. The connection is opened asynchronously and the result returned in the handler. Vertx::NetSocket

Parameters:

  • port. (FixNum)
    The port to connect to.
  • host. (String)
    The host or ip address to connect to.
  • hndlr (Block)
    A block to be used as the handler. The handler will be called with an exception or the

Returns:

  • (NetClient)
    A reference to self so invocations can be chained


97
98
99
100
101
# File 'src/main/api_shim/core/net.rb', line 97

def connect(port, host = "localhost", &hndlr)
  hndlr = ARWrappedHandler.new(hndlr) { |j_socket| NetSocket.new(j_socket) }
  @j_del.connect(port, host, hndlr)
  self
end

- (Object) connect_timeout(val = nil)

Set or Get the connect timeout for a fluent API


142
143
144
145
146
147
148
149
# File 'src/main/api_shim/core/net.rb', line 142

def connect_timeout(val = nil)
  if val
    @j_del.setConnectTimeout(val)
    self
  else
    @j_del.getConnectTimeout
  end
end

- (Object) connect_timeout=(val)

Set the connect timeout


136
137
138
139
# File 'src/main/api_shim/core/net.rb', line 136

def connect_timeout=(val)
  @j_del.setConnectTimeout(val)
  self
end

- (Object) reconnect_attempts(val = nil)

Set or Get the reconnect attempts for a fluent API


110
111
112
113
114
115
116
117
# File 'src/main/api_shim/core/net.rb', line 110

def reconnect_attempts(val = nil)
  if val
    @j_del.setReconnectAttempts(val)
    self
  else
    @j_del.getReconnectAttempts
  end
end

- (Object) reconnect_attempts=(val)

Set the reconnect attempts


104
105
106
107
# File 'src/main/api_shim/core/net.rb', line 104

def reconnect_attempts=(val)
  @j_del.setReconnectAttempts(val)
  self
end

- (Object) reconnect_interval(val = nil)

Set or Get the reconnect interval for a fluent API


126
127
128
129
130
131
132
133
# File 'src/main/api_shim/core/net.rb', line 126

def reconnect_interval(val = nil)
  if val
    @j_del.setReconnectInterval(val)
    self
  else
    @j_del.getReconnectInterval
  end
end

- (Object) reconnect_interval=(val)

Set the reconnect interval


120
121
122
123
# File 'src/main/api_shim/core/net.rb', line 120

def reconnect_interval=(val)
  @j_del.setReconnectInterval(val)
  self
end