#!/usr/bin/env ruby Thread.abort_on_exception = true require_relative '../lib/buschtelefon' include Buschtelefon # A # ↕ # B ↔ D ↔ E # ↓ ↑ # C → F tattlers = { A: Tattler.new, B: Tattler.new, C: Tattler.new, D: Tattler.new, E: Tattler.new, F: Tattler.new } tattlers[:A].connect(tattlers[:B]) tattlers[:B].connect(tattlers[:A]) tattlers[:B].connect(tattlers[:C]) tattlers[:C].connect(tattlers[:F]) tattlers[:F].connect(tattlers[:D]) tattlers[:B].connect(tattlers[:D]) tattlers[:D].connect(tattlers[:B]) tattlers[:D].connect(tattlers[:E]) tattlers[:E].connect(tattlers[:D]) puts 'Feeding locals' tattlers[:A].feed(Gossip.new('Tezos')) simon = NetTattler.new josua = NetTattler.new remote_simon = josua.connect_remote(host: '127.0.0.1', port: simon.port) threads = [ Thread.new { josua.listen { |gossip, source| puts "I'm Josua, I got \"#{gossip.message}\" from #{source}" } }, Thread.new { simon.listen { |gossip, source| puts "I'm Simon, I got \"#{gossip.message}\" from #{source}" } } ] sleep(0.1) remote_simon.feed(Gossip.new('Antshare')) sleep(0.1) remote_simon.inquire sleep(0.1) threads.each(&:exit)