lib/kamerling/net_dispatcher.rb in kamerling-0.0.2 vs lib/kamerling/net_dispatcher.rb in kamerling-0.0.3

- old
+ new

@@ -1,10 +1,15 @@ -module Kamerling module NetDispatcher - module_function +require 'socket' - def dispatch addr, bytes - case addr.prot - when :TCP then TCPSocket.open(*addr) { |socket| socket << bytes } - when :UDP then UDPSocket.new.send bytes, 0, *addr +module Kamerling + module NetDispatcher + module_function + + def dispatch(addr, message) + bytes = message.to_s + case addr.prot + when :TCP then TCPSocket.open(*addr) { |socket| socket << bytes } + when :UDP then UDPSocket.new.send bytes, 0, *addr + end end end -end end +end