Created
November 29, 2011 14:16
-
-
Save dongyuwei/1404937 to your computer and use it in GitHub Desktop.
em-channel for pub-sub
This file contains 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 '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