em-ucengine is a Ruby library for U.C.Engine powered by EventMachine
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
lib
spec
.autotest
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
em-ucengine.gemspec

README.md

EventMachine library for U.C.Engine

em-ucengine is a Ruby library for U.C.Engine powered by EventMachine. It can connect, subscribe and publish events to U.C.Engine.

Install

Install with Rubygems:

gem install em-ucengine

If you use bundler, add it to your Gemfile:

gem "em-ucengine", "~> 0.3"

Usage

Client

EventMachine

We have a classic block style API:

require "em-ucengine"
EventMachine::UCEngine::Client.run do |uce|
  uce.connect("participant", "pwd") do |err, session|
    EM.add_periodic_timer(1) { session.publish("em-ucengine.example.ping", "demo") }
    session.subscribe("demo") do |err, event|
      puts "Hey, we received an event: #{event.inspect}"
    end
  end
end

Each method call return a deferable.

require "em-ucengine"
EventMachine::UCEngine::Client.run do |uce|
  req = uce.connect("participant", "pwd")
  req.callback do |session|
    session.publish("em-ucengine.example.ping", "demo")
  end
  req.errback do |error|
     puts "error"
  end
end

Net/HTTP

require "em-ucengine"

uce = UCEngine::Client.new
session = uce.connect("participant", "pwd")
session.publish("em-ucengine.example.ping", "demo")

Brick

require "em-ucengine"
require "em-ucengine/brick"

class MyBrick
  include EM::UCEngine::Brick

  on "ping" do |event|
    puts event
  end
end

brick = MyBrick.run

Don't hesitate to look at the specs for more examples ;-)

TODO

  • Release the gem with another name
  • Complete the specs
  • Implements the download and upload methods for the Net::HTTP backend

Issues or Suggestions

Found an issue or have a suggestion? Please report it on Github's issue tracker.

First you must have an ucengine instance goto the source directory and start:

make run

Once the console started successfully, in an other shell

./rel/ucengine/bin/demo.sh localhost

If you wants to make a pull request, please check the specs before:

rake test

Copyright (c) 2011 af83, released under the LGPL license