Last active
August 29, 2015 14:08
-
-
Save boosty/80923cb86f0fa1864a5f to your computer and use it in GitHub Desktop.
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 'bundler/setup' | |
require 'ffi-rzmq' | |
context = ZMQ::Context.new | |
puts "Starting Listener..." | |
listener = context.socket(ZMQ::SUB) | |
listener.setsockopt(ZMQ::SUBSCRIBE, '') | |
range = (2..254) | |
puts "Connecting to 192.168.43.<#{range.inspect}>..." | |
range.each do |i| | |
listener.connect("tcp://192.168.43.#{i}:7315") | |
end | |
Thread.new do | |
loop do | |
msg = "" | |
listener.recv_string(msg) | |
puts msg if msg != "" | |
end | |
end | |
puts "Starting UI..." | |
ui = context.socket(ZMQ::PUB) | |
ui.bind("tcp://192.168.43.186:7315") | |
loop do | |
ui.send_string("<boosty> #{gets}") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment