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)


99
100
101
102
103
# File 'lib/omq/transport/udp.rb', line 99

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

Instance Method Details

#closeObject

Closes the underlying UDP socket.



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

def close
  @socket.close rescue nil
end

#curve?Boolean

Whether this connection uses CURVE encryption.

Returns:

  • (Boolean)

    always false



128
129
130
# File 'lib/omq/transport/udp.rb', line 128

def curve?
  false
end

#flushObject

No-op; UDP datagrams are sent immediately.



121
122
# File 'lib/omq/transport/udp.rb', line 121

def flush
end

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

Encodes and sends a datagram.

Parameters:

  • parts (Array<String>)
    group, body


110
111
112
113
114
115
116
# File 'lib/omq/transport/udp.rb', line 110

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