Skip to content

Instantly share code, notes, and snippets.

@mokevnin
Created September 22, 2011 12:21
Show Gist options
  • Save mokevnin/1234647 to your computer and use it in GitHub Desktop.
Save mokevnin/1234647 to your computer and use it in GitHub Desktop.
# sub.rb
require 'rubygems'
require 'zmq'
context = ZMQ::Context.new
chans = %w(rubyonrails ruby-lang)
sub = context.socket ZMQ::SUB
sub.connect 'tcp://127.0.0.1:5555'
sub.setsockopt ZMQ::SUBSCRIBE, 'id'
while line = sub.recv
chan, user, msg = line.split ' ', 3
puts "##{chan} [#{user}]: #{msg}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment