Class: David::Transmitter

Inherits:
Object
  • Object
show all
Includes:
Registry
Defined in:
lib/david/transmitter.rb

Constant Summary collapse

AF_INET6 =
'AF_INET6'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(socket) ⇒ Transmitter


7
8
9
10
# File 'lib/david/transmitter.rb', line 7

def initialize(socket)
  @log = Celluloid.logger
  @socket = socket || server.socket
end

Instance Method Details

#send(exchange) ⇒ Object

TODO Retransmissions


13
14
15
16
17
18
19
20
# File 'lib/david/transmitter.rb', line 13

def send(exchange)
  host = normalize_host(exchange.host)

  @socket.send(exchange.message.to_wire, 0, host, exchange.port)

  @log.info('-> ' + exchange.to_s)
  @log.debug(exchange.message.inspect)
end