class Protor::UDPClient
Attributes
connection[R]
formatter[R]
host[R]
port[R]
Public Class Methods
new(host, port, formatter)
click to toggle source
# File lib/protor/udp_client.rb, line 7 def initialize(host, port, formatter) @port = port @host = host @formatter = formatter end
Public Instance Methods
publish(payload)
click to toggle source
# File lib/protor/udp_client.rb, line 13 def publish(payload) connect do |conn| formatter.format(payload) do |msg| conn.send(msg, 0) end end end
Private Instance Methods
connect() { |connection| ... }
click to toggle source
# File lib/protor/udp_client.rb, line 23 def connect connection = UDPSocket.new connection.connect(host, port) yield(connection) ensure connection.close unless connection.closed? end