A real-time Talker Ruby client.
-
Get a Talker account at https://talkerapp.com/signup
-
Get your Talker Token on https://myaccount.talkerapp.com/settings
-
Find the Room ID you want to connect to. This is the last part of the URL:
-
Serve hot and enjoy
Talker.connect(:room => ROOM_ID, :token => YOUR_TALKER_TOKEN) do |client| client.on_connected do client.send_message "hello!" end
client.on_message do |user, message| puts user["name"] + ": " + message end
trap("INT") { client.close } end
All arguments are optional.
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 on_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.
user
is the sender.
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",... event specific attributes}
.
Methods of an instance of Talker class.
Info about the user currently connected, nil
if not yet connected:
{"id"=>1, "name"=>"macournoyer", "email"=>"macournoyer@talkerapp.com"}
Array of users currently in the room. In the form:
[{"id"=>1, "name"=>"macournoyer", "email"=>"macournoyer@talkerapp.com"},
{"id"=>2, "name"=>"gary", "email"=>"gary@talkerapp.com"}]
Leave the room and close the connection.
Close the connection without leaving the room.
Send a message.
Send a private message to user_name
.
Howdy brave lil' one! To run the specs you'll need courage, hard work and some luck:
-
Install from source my "special" fork of em-spec at http://github.com/macournoyer/em-spec.
-
Edit the file spec/talker.example.yml with your info and rename it to spec/talker.yml.
-
Run
rake
and everything should be green, birds should start signing and someone will make you a chocolate cake
(results may vary).
Released under the Ruby License, (c) Talker
Thanks to http://github.com/raggi for kicking this off.