Class: Vertx::NetServer

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

Overview

Represents a TCP server

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


21
22
23
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_server.rb', line 21

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

+ (Object) j_api_type



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

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



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

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

+ (Object) unwrap(obj)



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

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

+ (Object) wrap(obj)



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

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

Instance Method Details

- (Fixnum) actual_port

The actual port the server is listening on. This is useful if you bound the server specifying 0 as port number signifying an ephemeral port

Returns:

  • (Fixnum)
    the actual port the server is listening on.

Raises:

  • (ArgumentError)


106
107
108
109
110
111
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_server.rb', line 106

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.

Like #close but supplying a handler that will be notified when close is complete.

Yields:

  • the handler

Raises:

  • (ArgumentError)


95
96
97
98
99
100
101
102
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_server.rb', line 95

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

- (::Vertx::NetServer) connect_handler { ... }

Supply a connect handler for this server. The server can only have at most one connect handler at any one time. As the server accepts TCP or SSL connections it creates an instance of Vertx::NetSocket and passes it to the connect handler.

Yields:

Returns:

Raises:

  • (ArgumentError)


59
60
61
62
63
64
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_server.rb', line 59

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

- (::Vertx::ReadStream) connect_stream

Return the connect stream for this server. The server can only have at most one handler at any one time. As the server accepts TCP or SSL connections it creates an instance of Vertx::NetSocket and passes it to the connect stream .

Returns:

Raises:

  • (ArgumentError)


48
49
50
51
52
53
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_server.rb', line 48

def connect_stream
  if !block_given?
    return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:connectStream, []).call(),::Vertx::ReadStreamImpl,::Vertx::NetSocket.j_api_type)
  end
  raise ArgumentError, "Invalid arguments when calling connect_stream()"
end

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

Like #listen but providing a handler that will be notified when the server is listening, or fails.

Parameters:

  • port (Fixnum) (defaults to: nil)
    the port to listen on
  • host (String) (defaults to: nil)
    the host to listen on

Yields:

  • handler that will be notified when listening or failed

Returns:

  • (self)

Raises:

  • (ArgumentError)


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

def listen(port=nil,host=nil)
  if !block_given? && port == nil && host == nil
    @j_del.java_method(:listen, []).call()
    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,::Vertx::NetServer) : nil) }))
    return self
  elsif port.class == Fixnum && !block_given? && host == nil
    @j_del.java_method(:listen, [Java::int.java_class]).call(port)
    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,::Vertx::NetServer) : 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,::Vertx::NetServer) : nil) }))
    return self
  end
  raise ArgumentError, "Invalid arguments when calling listen(#{port},#{host})"
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)


38
39
40
41
42
43
# File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_server.rb', line 38

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