<!-- clanlib header begin --> <HTML> <HEAD> <TITLE>CL_IRCConnection - ClanLib Game SDK</TITLE> <STYLE TYPE="text/css"><!-- HTML BODY { font-family: verdana, helvetica, sans-serif; font-size: 12px; } H1 { font-size: 22px; } H2 { font-size: 18px; } H3 { font-size: 16px; } H4 { font-size: 14px; } P { font-size: 12px; } LI { font-size: 12px; } --></STYLE> </HEAD> <body bgcolor=white text=black link=blue vlink=#800080> <center> <img src="http://clanlib.org/gfx/clanlib.png"> </center> <!-- clanlib header end --> <center> <p> <a href="http://clanlib.org/docs.html">Home</a> | <a href="classes.html">All Classes</a> | <a href="modules.html">Grouped Classes</a> | <a href="index.html">Index</a> | <a href="search.html">Search</a> </p> </center> <h1>Class CL_IRCConnection</h1> <p> IRC Connection class. <a href="#description">More...</a></p> <p>Derived from: <i>none</i> <br> Derived by: <i>none</i> <br>Group: Network (Internet Relay Chat)</p> <p> #include <ClanLib/network.h> <p> <table border=0 width=100%> </table> <p><b>Construction:</b></p> <table border=0 width=100%> <tr><td width=30% valign=top><p><a href="CL_IRCConnection__CL_IRCConnection.html">CL_IRCConnection</a></p></td><td valign=top><p> Constructs a CL_IRCConnection and connects a server.</p></td></tr></table> <p><b>Attributes:</b></p> <table border=0 width=100%> <tr><td width=30% valign=top><p><a href="CL_IRCConnection__get_nick.html">get_nick</a></p></td><td valign=top><p> Returns our current nick name.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__get_username.html">get_username</a></p></td><td valign=top><p> Returns the username passed to send_user.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__get_hostname.html">get_hostname</a></p></td><td valign=top><p> Returns hostname passed to send_user.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__get_servername.html">get_servername</a></p></td><td valign=top><p> Returns server name passed to send_user.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__get_realname.html">get_realname</a></p></td><td valign=top><p> Returns the real name passed to send_user.</p></td></tr></table> <p><b>Operations:</b></p> <table border=0 width=100%> <tr><td width=30% valign=top><p><a href="CL_IRCConnection__operator =.html">operator =</a></p></td><td valign=top><p></p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_command.html">send_command</a></p></td><td valign=top><p> Send command to IRC server.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_pass.html">send_pass</a></p></td><td valign=top><p> Send password.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_nick.html">send_nick</a></p></td><td valign=top><p> Send nick.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_user.html">send_user</a></p></td><td valign=top><p> Send user login/identify command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_oper.html">send_oper</a></p></td><td valign=top><p> Send operator login command</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_quit.html">send_quit</a></p></td><td valign=top><p> Send quit command. </p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_join.html">send_join</a></p></td><td valign=top><p> Send join channel command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_part.html">send_part</a></p></td><td valign=top><p> Send part channel command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_mode.html">send_mode</a></p></td><td valign=top><p> Send set mode command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_topic.html">send_topic</a></p></td><td valign=top><p> Set/Get topic on channel.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_names.html">send_names</a></p></td><td valign=top><p> List nicks on channel(s).</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_list.html">send_list</a></p></td><td valign=top><p> Send list of channels.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_invite.html">send_invite</a></p></td><td valign=top><p> Send channel join invitation.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_kick.html">send_kick</a></p></td><td valign=top><p> Send kick command </p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_version.html">send_version</a></p></td><td valign=top><p> Send version command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_stats.html">send_stats</a></p></td><td valign=top><p> Send statistics command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_links.html">send_links</a></p></td><td valign=top><p> Send links command. </p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_time.html">send_time</a></p></td><td valign=top><p> Send time command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_connect.html">send_connect</a></p></td><td valign=top><p> Send connect command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_trace.html">send_trace</a></p></td><td valign=top><p> Send trace command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_admin.html">send_admin</a></p></td><td valign=top><p> Send admin command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_info.html">send_info</a></p></td><td valign=top><p> Send info command. </p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_privmsg.html">send_privmsg</a></p></td><td valign=top><p> Send channel message or private message.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_privmsg_ctcp.html">send_privmsg_ctcp</a></p></td><td valign=top><p> Send Client To Client Protocol (CTCP) message.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_notice.html">send_notice</a></p></td><td valign=top><p> Send notice message.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_notice_ctcp.html">send_notice_ctcp</a></p></td><td valign=top><p> Send Client To Client Protocol (CTCP) notice.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_who.html">send_who</a></p></td><td valign=top><p> Send who command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_whois.html">send_whois</a></p></td><td valign=top><p> Send whois command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_whowas.html">send_whowas</a></p></td><td valign=top><p> Send whowas command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_kill.html">send_kill</a></p></td><td valign=top><p> Send kill command.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_ping.html">send_ping</a></p></td><td valign=top><p> Send ping command</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__send_pong.html">send_pong</a></p></td><td valign=top><p> Send pong command</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__extract_nick.html">extract_nick</a></p></td><td valign=top><p> Extracts nick part of a fully qualified IRC prefix.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__extract_user.html">extract_user</a></p></td><td valign=top><p> Extracts user part of a fully qualified IRC prefix.</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__extract_address.html">extract_address</a></p></td><td valign=top><p> Extracts address part of a fully qualified IRC prefix.</p></td></tr></table> <p><b>Signals:</b></p> <table border=0 width=100%> <tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_socket_error.html">sig_socket_error</a></p></td><td valign=top><p> sig_socket_error(error_message)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_command_received.html">sig_command_received</a></p></td><td valign=top><p> sig_command_received(prefix, command, params)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_unknown_command_received.html">sig_unknown_command_received</a></p></td><td valign=top><p> sig_unknown_command_received(prefix, command, params)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_numeric_reply.html">sig_numeric_reply</a></p></td><td valign=top><p> sig_numeric_reply(prefix, code, params)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_name_reply.html">sig_name_reply</a></p></td><td valign=top><p> sig_name_reply(self, channel, users)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_nick.html">sig_nick</a></p></td><td valign=top><p> sig_nick(old_nick, new_nick)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_join.html">sig_join</a></p></td><td valign=top><p> sig_join(nick, channel)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_part.html">sig_part</a></p></td><td valign=top><p> sig_part(nick, channel, reason)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_mode.html">sig_mode</a></p></td><td valign=top><p> sig_mode(prefix, receiver, mode, params)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_topic.html">sig_topic</a></p></td><td valign=top><p> sig_topic(prefix, channel, topic)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_invite.html">sig_invite</a></p></td><td valign=top><p> sig_invite(prefix, nick, channel)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_kick.html">sig_kick</a></p></td><td valign=top><p> sig_kick(prefix, chan, user, comment)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_privmsg.html">sig_privmsg</a></p></td><td valign=top><p> sig_privmsg(prefix, receiver, text)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_notice.html">sig_notice</a></p></td><td valign=top><p> sig_notice(prefix, receiver, text)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_privmsg_ctcp.html">sig_privmsg_ctcp</a></p></td><td valign=top><p> sig_privmsg_ctcp(prefix, receiver, command, data)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_notice_ctcp.html">sig_notice_ctcp</a></p></td><td valign=top><p> sig_notice_ctcp(prefix, receiver, command, data)</p></td></tr><tr><td width=30% valign=top><p><a href="CL_IRCConnection__sig_ping.html">sig_ping</a></p></td><td valign=top><p> sig_ping(daemon1, daemon2)</p></td></tr></table> <a name="#description"><p><b>Detailed description:</b></p> !group=Network/Internet Relay Chat! !header=network.h! <p>The CL_IRCConnection class represents a socket connection to an IRC server. Upon construction it will connect to the server+port given and then parse each line written by the IRC server. Each time CL_System::keep_alive() is called, the CL_IRCConnection will emit the signals for those commands received.</p> <p>Most IRC networks will expect the connecting IRC client to first send a "nick" command and then a "user" command, as part of the logon process. CL_IRCConnection will not do this, so the general logon procedure looks somewhat like this:</p> <pre> CL_IRCConnection connection("irc.freenode.net", "6667"); connection.send_nick("MyNick"); connection.send_user("username", "our.hostname", "irc.freenode.net", "User Name"); </pre> <p>IRC servers will occationally send a "ping" line, which have to be replied with a "pong" command. If this isn't done within some server specific timeout, the IRC network will disconnect the client. CL_IRCConnection will also not do this automatically, so its important you at least hook up the ping slot, to a function looking like this:</p> <pre> void on_ping(const std::string &daemon1, const std::string &daemon2) { connection.send_pong(daemon1, daemon2); } </pre> <!-- clanlib footer begin --> <center><br><br><font color="#a0a0a0"> Questions or comments, write to the <a href="http://clanlib.org/contact.html">ClanLib mailing list</a>. </font></center> </body> </html> <!-- clanlib footer end -->