No commit activity in last 3 years
No release in over 3 years
Subscribe to channels with eventmachine
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
= 0.8.21
~> 0.11
~> 10.0
~> 3.7
~> 0.54
~> 0.14

Runtime

~> 1.2.5
~> 1.2.5
 Project Readme

Em::Pusher::Client

Gem Version Build Status Coverage Status

EventMachine client library for Pusher

Installation

Add this line to your application's Gemfile:

gem 'em-pusher-client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install em-pusher-client

Usage

EM.run do
  opts = {
    key: 'my-key',
    cluster: 'us2',
    port: 80,
    scheme: 'ws',
  }
  EM::Pusher::Client.connect(opts) do |conn|
    conn.connected do
      puts 'connected'
    end

    conn.callback do
      puts 'callback'
      msg = {
        event: 'pusher:subscribe',
        data: {
          channel: 'my-channel',
        },
      }
      conn.send_msg(msg)
    end

    conn.errback do |e|
      puts "Got error: #{e}"
    end

    conn.stream do |msg|
      puts "stream: <#{msg}>"
      case msg.event
      when 'pusher:connection_established'
        puts 'Connection Established'
      when 'pusher_internal:subscription_succeeded'
        puts "Subscribed to #{msg.json['channel']}"
      when 'someevent'
        puts "someevent: #{msg.data}"
      end
    end

    conn.disconnect do
      puts 'gone'
      EM.stop_event_loop
    end
  end
end

Development

After checking out the repo, run bin/setup to install dependencies. You can also run rake console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/em-pusher-client.