Module: Alo7::Net::Connection::Callbacks

Included in:
Alo7::Net::Connection
Defined in:
lib/alo7/net/connection.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#connection_completedvoid

This method returns an undefined value.

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


42
43
# File 'lib/alo7/net/connection.rb', line 42

def connection_completed
end

#post_initvoid

This method returns an undefined value.

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


32
33
# File 'lib/alo7/net/connection.rb', line 32

def post_init
end

#receive_data(data) ⇒ void

This method returns an undefined value.

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.

Parameters:

  • data (String)

    data received from the remote end

See Also:


55
56
# File 'lib/alo7/net/connection.rb', line 55

def receive_data(data)
end

#unbindvoid

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.

This method returns an undefined value.

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 Alo7::Net::Connection#disconnect), because of the remote end closed the connection, or because of a network error.


71
72
# File 'lib/alo7/net/connection.rb', line 71

def unbind
end