Skip to content
This repository
Newer
Older
100644 26 lines (21 sloc) 0.575 kb
59258c4e » justincase
2011-06-29 Added durapub/sub examples in Ruby
1 # Durable subscriber
2 # Justin Case <justin@playelite.com>
3
4 require 'ffi-rzmq'
5
6 context = ZMQ::Context.new
7
8 # Connect our subscriber socket
9 subscriber = context.socket(ZMQ::SUB)
10 subscriber.setsockopt(ZMQ::IDENTITY, "Hello")
11 subscriber.setsockopt(ZMQ::SUBSCRIBE, "")
12 subscriber.connect("tcp://127.0.0.1:5565")
13
14 # # Synchronize with publisher
15 sync = context.socket(ZMQ::PUSH)
16 sync.connect("tcp://127.0.0.1:5564")
17 sync.send_string("")
18
19 # Get updates, exit when told to do so
20 loop do
83bef6c3 » epugh
2011-11-14 tweaks to use api correctly
21 subscriber.recv_string(message = '')
59258c4e » justincase
2011-06-29 Added durapub/sub examples in Ruby
22 puts message
23 if message == "END"
24 break
25 end
26 end
Something went wrong with that request. Please try again.