Module: Kamerling::NetDispatcher

Defined in:
lib/kamerling/net_dispatcher.rb

Class Method Summary collapse

Class Method Details

.dispatch(addr, message) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/kamerling/net_dispatcher.rb', line 7

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