Class: OMQ::Transport::UDP::Dialer

Inherits:
Object
  • Object
show all
Defined in:
lib/omq/transport/udp.rb

Overview

A UDP dialer — registers a single RadioConnection with the engine.

UDP is connectionless; #connect is a one-shot registration. The reconnect loop will break out after the first successful call.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint, engine) ⇒ Dialer

Returns a new instance of Dialer.

Parameters:

  • endpoint (String)
  • engine (Engine)


103
104
105
106
# File 'lib/omq/transport/udp.rb', line 103

def initialize(endpoint, engine)
  @endpoint = endpoint
  @engine   = engine
end

Instance Attribute Details

#endpointString (readonly)

Returns the endpoint this dialer sends to.

Returns:

  • (String)

    the endpoint this dialer sends to



97
98
99
# File 'lib/omq/transport/udp.rb', line 97

def endpoint
  @endpoint
end

Instance Method Details

#connectvoid

This method returns an undefined value.

Registers a RadioConnection with the engine.



113
114
115
116
117
118
# File 'lib/omq/transport/udp.rb', line 113

def connect
  host, port = UDP.parse_endpoint(@endpoint)
  socket     = UDPSocket.new
  conn       = RadioConnection.new(socket, host, port)
  @engine.connection_ready(conn, endpoint: @endpoint)
end