Class: OMQ::Transport::UDP::RadioConnection

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

Overview

Outgoing UDP connection for RADIO sockets.

Intentionally does not implement #read_frame — this signals Routing::Radio to skip the group listener and use ANY_GROUPS.

Instance Method Summary collapse

Constructor Details

#initialize(socket, host, port) ⇒ RadioConnection

Returns a new instance of RadioConnection.

Parameters:

  • socket (UDPSocket)
  • host (String)
  • port (Integer)


133
134
135
136
137
# File 'lib/omq/transport/udp.rb', line 133

def initialize(socket, host, port)
  @socket = socket
  @host   = host
  @port   = port
end

Instance Method Details

#closeObject

Closes the underlying UDP socket.



168
169
170
# File 'lib/omq/transport/udp.rb', line 168

def close
  @socket.close rescue nil
end

#curve?Boolean

Whether this connection uses CURVE encryption.

Returns:

  • (Boolean)

    always false



162
163
164
# File 'lib/omq/transport/udp.rb', line 162

def curve?
  false
end

#flushObject

No-op; UDP datagrams are sent immediately.



155
156
# File 'lib/omq/transport/udp.rb', line 155

def flush
end

#write_message(parts) ⇒ Object Also known as: send_message

Encodes and sends a datagram.

Parameters:

  • parts (Array<String>)
    group, body


144
145
146
147
148
149
150
# File 'lib/omq/transport/udp.rb', line 144

def write_message(parts)
  group, body = parts
  datagram = UDP.encode_datagram(group.to_s, body.to_s)
  @socket.send(datagram, 0, @host, @port)
rescue Errno::ECONNREFUSED, Errno::ENETUNREACH
  # UDP fire-and-forget — drop silently
end