module Alo7::Net::Connection::Callbacks

This method declaires the callbacks users can overwrite to implement their own business logics.

Public Instance Methods

connection_completed() click to toggle source

Called by the event loop when a remote TCP connection attempt completes successfully.

@return [void]

@see Net.connect @see post_init

# File lib/alo7/net/connection.rb, line 42
def connection_completed
end
post_init() click to toggle source

Called by the event loop immediately after the network connection has been established, and before resumption of the network loop.

@return [void]

@see connection_completed

# File lib/alo7/net/connection.rb, line 32
def post_init
end
receive_data(data) click to toggle source

Called by the event loop whenever data has been received by the network connection. It’s called with a single parameter, a String containing the network protocol data, which may of course be binary. You will generally overwrite this method to perform your own processing of the incoming data.

@param data [String] data received from the remote end @return [void]

@see send_data

# File lib/alo7/net/connection.rb, line 55
def receive_data(data)
end
unbind() click to toggle source

Called by the event loop whenever a connection (either a server or a client connection) is closed. The close can occur because of your code intentionally (using {#disconnect}), because of the remote end closed the connection, or because of a network error.

@return [void]

@see disconnect

@note You may not assume that the network connection is still open and

able to send or receive data when the callback to unbind is made.
This is intended only to give you a chance to clean up associations
your code may have made to the connection object while it was open.
# File lib/alo7/net/connection.rb, line 71
def unbind
end