Skip to content

voodootikigod/talker.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

talker.js

(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.

Usage

  1. Get a Talker account at https://talkerapp.com/signup

  2. Get your Talker Token on https://user_name.talkerapp.com/settings

  3. Find the Room ID you want to connect to. This is the last part of the URL:

    https://user_name.talkerapp.com/rooms/<room_id>

  4. 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();

  5. Register your callbacks using the API below.

    log_client.addListener("message", function(msg) { sys.puts(obj.user.name+': '+obj.content); });

  6. 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.

Callbacks

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.

connected

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"}.

presence(users)

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"}]

message

Called when a new message is received.

private_message(user, message)

Called when a new private message is received. user is the sender.

join(user)

Called when a user joins the room.

idle(user)

Called when a user becomes idle (closed connection without leaving).

back(user)

Called when a user is back from idle.

leave(user)

Called when a user leaves.

close

Called when the connection is closed.

error(error_message)

Called when an error is received from the Talker server.

event(event)

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.

Credits

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!

About

A node.js client for talkerapp.com

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published