Boucherot::Connection - A connection class for the boucherot bot
This is class is the parent for all the connections that the boucherot bot can use.
The IRC connection inherit from Boucherot::Connection, but also DCC connections or even masta connection or any connection you could imagine or add.
All the connections are designed to works with a SetOfConnections (see Boucherot::SetOfConnections)
This class was at the beggining derivated from Net::IRC::Connection, but for a lot of reasons, the boucherot project is now independant from Net::IRC.
class Boucherot::Connection
Attributs :
+ server + port + socket + error + context + mid
- frag - connected - parent - set_of_connections
-$ current
Methods :
+$ new ( parent , ... ) : Boucherot::Connection
Read
+ id () : SCALAR + connect ( ... ) : Boolean + on_connected () : + removable () : Boolean
Write
+ disconnect () : + on_disconnected () : + rawsend ( rawline ) : + ircsend ( line ) : + printerr ( error ) : + schedule ( time, code ) :
Action
+ parse () : + parse_line ( line ) :
Read || Write
+ current () : Boucherot::Connection +$ current () : Boucherot::Connection + connected () : Boolean + connected ( status : Boolean ) : Boolean
+ parent ( parent : Boucherot::Midable ) : Boucherot::Midable + parent ( ) : Boucherot::Midable + set_of_connection ( ... ) : Boucherot::SetOfConnections
Read
# blocget () : SCALAR # getline () : ( line, line, ... ) : ARRAY
Write
# disconnect () : # on_connected () : # on_disconnected () : # reconnect () : # connect_as_client ( 'port' => port, 'server' => server, ... ) : Boolean
Action
# parse () :
- DESTROY () :
+$ new ( parent , ... ) : Boucherot::Connection
Create a new connection and connect with the arguments.
+ init_instance ( ... ) :
init_instance is called each time a connection is created.
It's auto-called between the connnection is created and the socket is opened.
+ id () : SCALAR
This method is for idententifying the connection by a unique way. This is use, for example to log events with the connection that created them.
It's a string. The default is the package name followed by a unique hexa number
+ connect ( ... ) : Boolean
``Connect'' the Connection. The default action is to call the protected method _connect_as_client that take a HASH table.
+ on_connected () :
Call each time a connection have been connected. Override only the protected one.
+ removable () : Boolean
Return true if the connection should be remove once it has been closed.
The default is true.
+ disconnect () :
``disconnect'' call the protected method _disconnect and then reconnect. You should override only the two last methods.
+ on_disconnected () :
Called on each socket disconnected. Here, the socket IS already closed. The socket may have been closed by the other side or by this side.
You should only override the protected on_disconnected.
+ rawsend ( rawline ) :
Send a raw line to the socket.
+ ircsend ( line ) :
Send a line and add an IRC cariage return (CRLF) to the socket.
+ printerr ( error ) :
Print an error.
+ schedule ( time, code ) :
schedule the execution of the method ``code'' in ``time'' seconds.
+ timer ( time, code ) :
schedule the execution of the method ``code'' in ``time'' seconds.
+ parse () :
That method is called each time a socket event occured. That method just call the protected one _parse.
+ parse_line ( line ) :
That method is the default method that is called for each line received from socket.
+ current () : Boucherot::Connection +$ current () : Boucherot::Connection
Get or Set the current instance for Boucherot::Connection.
+ connected () : Boolean + connected ( status : Boolean ) : Boolean
Get or Set the status of the connection's socket.
+ parent ( parent : Boucherot::Midable ) : Boucherot::Midable + parent ( ) : Boucherot::Midable
Get or Set the parent for the current connection
+ set_of_connections ( ... ) : Boucherot::SetOfConnections
Get the current set of connections. compatibility
# blocget () : SCALAR
Get the bloc size to retrieve each time ``parse'' is called.
# getline () : ( line, line, ... ) : ARRAY
Get some lines from the socket.
# disconnect () :
disconnect the socket. That method never try to reconnect. Internal use only.
# on_connected () :
Called on each socket connected.
You should override this one.
# on_disconnected () :
Called on each socket disconnected. Here, the socket IS already closed. The socket may have been closed by the other side or by this side.
You should override this one.
# reconnect () :
That method do nothing, but should be overiden if your connection should auto-reconnect.
# connect_as_client ( 'port' => port, 'server' => server, ... ) : Boolean
This is the implementation of ``connect'' for a typical client instance.
# parse () :
use the protected ``getline'' method, and for each line, call parse_line.
- DESTROY () :
Destroy the instance.
This class was written by Arthibus Gissehel <gissehel@vachefolle.com> in 2000.
This use some Net::IRC code that has it's own authors, see Net::IRC
Copyrights and NOTES section.
Boucherot::Connection is closed to Net::IRC::Connection
In fact, this class was a child of Net::IRC::Connection. But, for many reasons, it's now an independant project. Note that a lot code is ``Copyright (c) 1997 Greg Bacon & Dennis Taylor. All rights reserved.''
Note also that the Net::IRC's license (same as perl itself) also apply to Boucherot::Connection (see COPYING)