class Buschtelefon::RemoteTattler

No need to inheritance from Tattler because not all its features are available here (only feed)

Attributes

host[R]
port[R]

Public Class Methods

new(host:, port:, outbound_socket: UDPSocket.new) click to toggle source
# File lib/buschtelefon/remote_tattler.rb, line 8
def initialize(host:, port:, outbound_socket: UDPSocket.new)
  @host = host
  @port = port
  @outbound_socket = outbound_socket
end

Public Instance Methods

feed(gossip) click to toggle source
# File lib/buschtelefon/remote_tattler.rb, line 14
def feed(gossip)
  # puts "#{@outbound_socket.local_address.ip_port} sending #{JSON.parse(gossip.message)['number']} to #{@port}"
  @outbound_socket.send(gossip.message, 0, @host, @port)
end
inquire() click to toggle source
# File lib/buschtelefon/remote_tattler.rb, line 19
def inquire
  @outbound_socket.send("\x05", 0, @host, @port)
end
to_s() click to toggle source
# File lib/buschtelefon/remote_tattler.rb, line 23
def to_s
  "#{@host}:#{@port}"
end