#!/usr/local/bin/ruby
####################################################################
# user.rb
# This is a partial implemntation o the demo program user distributed
# with Spread, rewritten in ruby.
# Copyright(2001) George Schlossnagle
####################################################################
require "./spread.so";
print "What name would you like to go by?>"
name = gets
name.chomp!
print "What group would you like to join?>"
group = gets
group.chomp!
conn = Spread.new("3456", name);
conn.join(group)
fork do
	while(1)
		recv_mess = conn.receive
		print recv_mess.sender, " says " , recv_mess.message, "\n"
	end	
end

while(1)
	print "User> "
	send_mess = gets
	send_mess.chomp!
	if(send_mess != "")
		conn.multicast(send_mess, group, Spread::RELIABLE_MESS)
	end
end


syntax highlighted by Code2HTML, v. 0.9.1