Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

98 lines (84 sloc) 5.846 kB
<h1>:node-irc:</h1>
<p><em>Simple binding of libircclient for node.js.</em></p>
<h3>1. USAGE</h3>
<p><code>javascript <br />
irc = require("./build/default/binding") <br />
//prepare callbacks <br />
callbacks = new Object(); <br />
callbacks.connectCallback = function (session, even, origin, params) <br />
{ <br />
irc.Join(session, "#test_node", ""); <br />
irc.SendMsg(session, "#test_node", "Hello everybody on the channel"); <br />
} <br />
session = irc.CreateSession(callbacks); <br />
irc.Connect(session, "irc.freenode.net", 6667, "", "", "happy_nodejs_user", "", ""); <br />
irc.Run(session); <br />
//there is no thread.join, so you need to create forever-loop (for example http server) to proceed. <br />
while (1) <br />
{ <br />
}
</code></p>
<h3>2. MODULE DESCRIPTION</h3>
<h4>Functions:</h4>
<ul>
<li><code>Session CreateSession(Callbacks callbacks)</code> <br />
Creates an unique javascript object <code>Session</code> which will identify your IRC session</li>
<li><code>Number Connect(Session session, Number port, String password, String nick, String username, String realname)</code> <br />
Creates connection to the server. Returns 0 if success.</li>
<li><code>Run(Session session)</code> <br />
Starts an IRC-session - processing callbacks, sending messages etc. Implemented non-blocking.</li>
<li><code>Integer Disconnect(Session session)</code> <br />
Disconnects from IRC-server, free memory ocupied by user-callbacks.</li>
<li><code>Integer Join(Session session, String channel, String key)</code> <br />
Join IRC-channel <code>channel</code> with passphrase <code>key</code></li>
<li><code>Integer SendMsg(Session session, String destination, String text)</code> <br />
Send a message <code>text</code> to channel/nick <code>destination</code></li>
<li><code>Integer Part(Session session, String channel)</code> <br />
Part channel <code>channel</code> and stop talking here.</li>
<li><code>Integer Invite(Session session, String nick, String channel)</code> <br />
Invite user <code>nick</code> to channel <code>channel</code>.</li>
<li><code>Integer Mode(Session session, String channel, String mode)</code> <br />
Set mode (ex. +b -t etc) <code>mode</code> for channel <code>channel</code>.</li>
<li><code>Integer Kick(Session session, String nick, String channel, String reason)</code> <br />
Kick user <code>nick</code> from <code>channel</code> for <code>reason</code>.</li>
<li><code>Integer Topic(Session sessiom, String channel, String topic)</code> <br />
Set <code>topic</code> for <code>channel</code>.</li>
</ul>
<h4>Callbacks object fields:</h4>
<p>All callback arguments are similar to their equivalents in <a href="http://libircclient.sourceforge.net">libircclient library</a>.</p>
<ul>
<li><code>connectCallback(Session session, String event, String origin, Array params)</code> </li>
<li><code>recieveCallback(Session session, String event, String origin, Array params)</code> </li>
<li><code>joinCallback(Session session, String event, String origin, Array params)</code> </li>
<li><code>partCallback(Session session, String event, String origin, Array params)</code> </li>
<li><code>nickCallback(Session session, String event, String origin, Array params)</code> </li>
</ul>
<hr />
<h3>3. COMMIT HISTORY</h3>
<pre><code>10.03.11: First commit: README, package.json files, TODO list
17.03.11: Added accessors for channel connection processing
12.04.11: Testing environment for libircclient and libev - testirc
19.04.11: Working tests: sending and recieving messages via console works well. Handling connected/recieved message events. New design of main module file (binding.cc)
20.04.11: CreateSession function prototype done. Arguments now are two callback functions
20.04.11: Persistent callback functions done. Now we can describe callbacks directly from javascript
25.04.11: Functions SendMsg, Join done, now everything can be done directly from JS
27.04.11: All about IRC events now works in another thread. ConnectCallback is working. Everything works in parallel with nodejs event loop. Web server and irc connection in example test.js
28.04.11: RecievedCallback events. Testing Web-page on 127.0.0.1:8100 - wait for connection to be viewed from console. Everything works fine, but we need a new arquitect to hold many irc connections. For showtime - small javascript which populates the page with new irc messages.
03.05.11: Testing web-page with chat window. Fixed some errors with memory management.
11.05.11: Many fixes, function Run() now works fine and is non-blocking. Time to begin with lots of sessions.
16.05.11: All callbacks for irc.SessionCreate(x) now are in a JavaScript object x.
17.05.11: Works with multiple sessions!
17.05.11: Two users in test.js: one for web-ui and one just bot.
25.05.11: Fixed bugs on 64-bit systems, state UML diagram.
25.05.11: Sequence UML diagram; header file binding.h with all necesarry information about JS functions.
26.05.11: Session now is an object returned by CreateSession(..); Disconnect function, callback fix.
26.05.11: Everything without prototypes. Just require("way_to_module"). You can choose nick on your testing page.
30.05.11: Common callback function written, base for implementing every one necessarry callback (joinCallback, partCallback for ex.); test.js modified for ex.)
30.05.11: Callbacks for: nick, part, join events. Testing script test.js.
30.05.11: Modified bot.
30.05.11: All callbacks now are dispatched by cmn_cb.
31.05.11: Modified documentation - view README.md/README.html.
31.05.11: Functions: Part, Invite, Kick, Mode, Topic. Test how bot leaves channel - test.js.
01.06.11: Performance testing perf_test.js, modified sources for better performance.
</code></pre>
<hr />
Jump to Line
Something went wrong with that request. Please try again.