#!/usr/bin/env ruby banner =< peer_port, :peer_handler => ExampleHandler.new, :groups => ['im_example']) # Let the magic begin! journeta.start # You can use the following helper to automatically stop the given engine when the application is killed with CTRL-C. include Journeta::Common::Shutdown stop_on_shutdown(journeta) # Alternatively, you can stop the engine manually by calling +Engine#stop+. # Do this before exiting to broadcast a message stating you are going offline as a courtesy to your peers, like so.. # @journeta.stop puts "What's your name?" name = gets # The `known_peers` call allows you to access the registry of known available peers on the network. # The UUID associated which each peer will be unique accross the network. peers = journeta.known_peers if peers.size > 0 puts 'The following peers IDs are online..' peers.each do |uuid, peer| puts " #{uuid}; version #{peer.version}" end else puts 'No peers known. (Start another client!)' end # Sit around are watch events at the console until the user hits puts 'Text you enter here will automatically be shown on peers terminals.' begin loop do begin input = gets m = BasicMessage.new m.name = name m.text = input journeta.send_to_known_peers(m) end end end # The engine can be restarted and stopped as many times as you'd like. #journeta.start #journeta.stop