= PusherClient

pusher-client is a ruby gem for consuming WebSockets from the Pusher webservice[http://pusherapp.com]

It is driven by event-machine and maintains a connection to Pusher, optionally in its own thread.

== Installation
  gem install pusher-client
== Evented Usage
The application will pause at socket.connect and handle events from Pusher as they happen.

  require 'pusher-client'
  PusherClient.logger = Logger.new(STDOUT)
  socket = PusherClient::Socket.new(YOUR_APPLICATION_KEY)

  # Bind to a global event
  socket.bind('globalevent') do |data|
    puts data
  end

  # Subscribe to a channel
  socket.subscribe('mychannel')

  # Bind to a channel event
  socket['mychannel'].bind('channelevent') do |data|
    puts data
  end

  socket.connect

== Asynchronous Usage
The socket will remain open in the background as long as your main application thread is running,
and you can continue to subscribe/unsubscribe to channels and bind new events.

  require 'pusher-client'
  PusherClient.logger = Logger.new(STDOUT)
  socket = PusherClient::Socket.new(YOUR_APPLICATION_KEY)
  socket.connect(true) # Connect asynchronously

  # Bind to a global event
  socket.bind('globalevent') do |data|
    puts data
  end

  # Subscribe to a channel
  socket.subscribe('mychannel')

  # Bind to a channel event
  socket['mychannel'].bind('channelevent') do |data|
    puts data
  end

  loop do
    sleep(1)
  end

For further documentation, read the source & test suite. Some features of the JavaScript client
are not yet implemented.

== Contributing to pusher-client
 
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

Copyright (c) 2010 Logan Koester. See LICENSE.txt for
further details.