Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Created November 29, 2011 14:16
Show Gist options
  • Save dongyuwei/1404937 to your computer and use it in GitHub Desktop.
Save dongyuwei/1404937 to your computer and use it in GitHub Desktop.
em-channel for pub-sub
require 'rubygems'
require 'eventmachine'
EM.run{
channel = EM::Channel.new
sid = channel.subscribe{ |topic,msg| p [topic, msg] }
channel.push(['topic',{'key1'=>'value1'}])
channel.push({'topic'=>'test','msg'=>{'a'=>'b'}})
channel.unsubscribe(sid)
EM.stop
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment