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:
-
{#post_init}
-
{#connection_completed}
-
{#receive_data}
-
{#unbind}
@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
@private
Public Class Methods
@param args passed from {listen} or {connect}
# File lib/alo7/net/connection.rb, line 81 def initialize(*args) end
Public Instance Methods
(see Impl#await
)
# File lib/alo7/net/connection.rb, line 109 def await(defer) @impl.await defer end
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 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