Class: Staccato::Adapter::UDP

Inherits:
Object
  • Object
show all
Defined in:
lib/staccato/adapter/udp.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ UDP

Takes a URI with host/port

e.g.: URI('udp://127.0.0.1:3001')


9
10
11
12
13
14
# File 'lib/staccato/adapter/udp.rb', line 9

def initialize(uri)
  @host = uri.host
  @port = uri.port

  @socket = UDPSocket.new
end

Instance Method Details

#post(params) ⇒ Object



16
17
18
19
20
# File 'lib/staccato/adapter/udp.rb', line 16

def post(params)
  body = URI.encode_www_form(params)

  @socket.send(body, 0, @host, @port)
end