Class List Method List File List

# Class: Vertx::NetServer

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

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

## Instance Method Summary (collapse)

- - (Fixnum) actual_port
  The actual port the server is listening on.
- - (void) close { ... }
  Like #close but supplying a handler that will be notified when close is complete.
- - (::Vertx::NetServer) connect_handler { ... }
  Supply a connect handler for this server.
- - (::Vertx::ReadStream) connect_stream
  Return the connect stream for this server.
- - (self) exception_handler { ... }
  Set an exception handler called for socket errors happening before the connection is passed to the #connect_handler, e.g during the TLS handshake.
- - (self) listen(param_1 = nil, param_2 = nil)
  Like #listen but providing a handler that will be notified when the server is listening, or fails.
- - (true, false) metrics_enabled?
  Whether the metrics are enabled for this measured object.

## Class Method Details

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

Returns:

- (`Boolean`)

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

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

### + (`Object`) j_api_type

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

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

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

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

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

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

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

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

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

    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`)

    141
    142
    143
    144
    145
    146
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_server.rb', line 141

    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`)

    130
    131
    132
    133
    134
    135
    136
    137
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_server.rb', line 130

    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:

- (`::Vertx::NetServer`) —
  a reference to this, so the API can be used fluently

Raises:

- (`ArgumentError`)

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

    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:

- (`::Vertx::ReadStream`) —
  the connect stream

Raises:

- (`ArgumentError`)

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

    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`) exception_handler { ... }

Set an exception handler called for socket errors happening before the connection is passed to the #connect_handler, e.g during the TLS handshake.

Yields:

- the handler to set

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    120
    121
    122
    123
    124
    125
    126
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_server.rb', line 120

    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

### - (`self`) listen - (`self`) listen(listenHandler) { ... } - (`self`) listen(port) - (`self`) listen(localAddress) - (`self`) listen(port, host) - (`self`) listen(port, listenHandler) { ... } - (`self`) listen(localAddress, listenHandler) { ... } - (`self`) listen(port, host, listenHandler) { ... }

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

Overloads:

- - (`self`) listen(listenHandler) { ... }

  Yields:

  - handler that will be notified when listening or failed
- - (`self`) listen(port)

  Parameters:

  - port (`Fixnum`)
- - (`self`) listen(localAddress)

  Parameters:

  - localAddress (`::Vertx::SocketAddress`) —
    the local address to listen on
- - (`self`) listen(port, host)

  Parameters:

  - port (`Fixnum`)
  - host (`String`)
- - (`self`) listen(port, listenHandler) { ... }

  Parameters:

  - port (`Fixnum`) —
    the port to listen on

  Yields:

  - handler that will be notified when listening or failed
- - (`self`) listen(localAddress, listenHandler) { ... }

  Parameters:

  - localAddress (`::Vertx::SocketAddress`) —
    the local address to listen on

  Yields:

  - handler that will be notified when listening or failed
- - (`self`) listen(port, host, listenHandler) { ... }

  Parameters:

  - port (`Fixnum`) —
    the port to listen on
  - host (`String`) —
    the host to listen on

  Yields:

  - handler that will be notified when listening or failed

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx/net_server.rb', line 88

    def listen(param_1=nil,param_2=nil)
      if !block_given? && param_1 == nil && param_2 == nil
        @j_del.java_method(:listen, []).call()
        return self
      elsif block_given? && param_1 == nil && param_2 == 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 param_1.class == Fixnum && !block_given? && param_2 == nil
        @j_del.java_method(:listen, [Java::int.java_class]).call(param_1)
        return self
      elsif param_1.class.method_defined?(:j_del) && !block_given? && param_2 == nil
        @j_del.java_method(:listen, [Java::IoVertxCoreNet::SocketAddress.java_class]).call(param_1.j_del)
        return self
      elsif param_1.class == Fixnum && param_2.class == String && !block_given?
        @j_del.java_method(:listen, [Java::int.java_class,Java::java.lang.String.java_class]).call(param_1,param_2)
        return self
      elsif param_1.class == Fixnum && block_given? && param_2 == nil
        @j_del.java_method(:listen, [Java::int.java_class,Java::IoVertxCore::Handler.java_class]).call(param_1,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil, ar.succeeded ? ::Vertx::Util::Utils.safe_create(ar.result,::Vertx::NetServer) : nil) }))
        return self
      elsif param_1.class.method_defined?(:j_del) && block_given? && param_2 == nil
        @j_del.java_method(:listen, [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::NetServer) : nil) }))
        return self
      elsif param_1.class == Fixnum && param_2.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(param_1,param_2,(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(#{param_1},#{param_2})"
    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`)

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

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