Created
January 5, 2010 05:45
-
-
Save macournoyer/269171 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "talker" | |
| module Connection | |
| attr_accessor :client | |
| def data_received(data) | |
| client.send_message data | |
| end | |
| end | |
| Talker::Client.connect(:room => room, :token => token) do |client| | |
| client.on_connected do | |
| @connection = EM.connect "0.0.0.0", 8000, Connection | |
| @connection.client = client | |
| end | |
| client.on_message do |user, message| | |
| @connection.send_data message | |
| end | |
| client.on_error do |error| | |
| puts error | |
| end | |
| client.on_close do | |
| EM.stop | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment