class Alo7::Net::Connection

This is a class that is instantiated by the event loop whenever a new connection is created. New connections can be created by {listen accepting a remote client} or {connect connecting to a remote server}.

Users should overwrite {#initialize}, following callbacks included from {Callbacks} to implement their own business logics:

@note This class is considered to be a base class. Use the derived class

{Server} or {Client} instead of this class directly.

@note This class should never be instantiated by user code.

Attributes

impl[RW]

@private

Public Class Methods

new(*args) click to toggle source

@param args passed from {listen} or {connect}

# File lib/alo7/net/connection.rb, line 81
def initialize(*args)
end

Public Instance Methods

await(defer) click to toggle source

(see Impl#await)

# File lib/alo7/net/connection.rb, line 109
def await(defer)
  @impl.await defer
end
disconnect() click to toggle source

Close the connection asynchronously after all of the outbound data has been written to the remote end. {#unbind} will be called later after this method returns.

@return [void]

@see unbind

# File lib/alo7/net/connection.rb, line 104
def disconnect
  @impl.close_connection_after_writing
end
send_data(data) click to toggle source

Send the data to the remote end of the connection asynchronously.

@param data [String] data to send @return [void]

@see receive_data

@note Data is buffered to be send which means it is not guaranteed to be

sent immediately when calling this method.
# File lib/alo7/net/connection.rb, line 93
def send_data(data)
  @impl.send_data data
end