(C) Chris Williams (voodootikigod@gmail.com) 2009, Licensed under the MIT-LICENSE
An client library for accessing Talker API services. It wraps up the streaming JSON API protocol and makes it consumable through various callbacks which are passed the returned JSON object. I have provided a simple logger application, aptly named logger.js, that simply records daily logs of activity.
-
Get a Talker account at https://talkerapp.com/signup
-
Get your Talker Token on https://user_name.talkerapp.com/settings
-
Find the Room ID you want to connect to. This is the last part of the URL:
-
Either update the provided config.template.js with the values or just use an inline object to pass the configuration to a new talker.Client(confg). Example:
var talker = require("./lib/talker"), repl= require("repl"); log_client = new talker.Client(config); log_client.connect();
-
Register your callbacks using the API below.
log_client.addListener("message", function(msg) { sys.puts(obj.user.name+': '+obj.content); });
-
Run using node filename.js and enjoy the good life.
NOTE: You must have either a repl("") call or some other keep alive construct at the end of your code to keep the server up so the data can continually stream. REPL nicely blocks for you, so its a bit more efficient and effective, especially since you can use it to dynamically update your client.
You do not need to register any of these and if you are using the REPL, you can register them at any time and they will work.
Called when the user is authenticated and ready to receive events. "user" is a Hash containing your user info: {"id"=>1, "name"=>"macournoyer", "email"=>"macournoyer@talkerapp.com"}
.
Called after connected
with the list of connected users. With users
being something like this:
[{"id"=>1, "name"=>"macournoyer", "email"=>"macournoyer@talkerapp.com"},
{"id"=>2, "name"=>"gary", "email"=>"gary@talkerapp.com"}]
Called when a new message is received.
Called when a new private message is received.
user
is the sender.
Called when a user joins the room.
Called when a user becomes idle (closed connection without leaving).
Called when a user is back from idle.
Called when a user leaves.
Called when the connection is closed.
Called when an error is received from the Talker server.
Called when any kind of event (all of the above) is received. "event" is a Hash: {"type":"event type","id":"unique ID",... event specific attributes}
.
NOTE API Documentation has been ported from Marc-André Cournoyer Ruby version.
Thanks go to Marc-André Cournoyer and Gray Haran for talker app. Who ever buys my next beer will get their name in shining lights here!