lib/propono/services/publisher.rb in propono-0.6.3 vs lib/propono/services/publisher.rb in propono-0.7.0

- old
+ new

@@ -1,5 +1,7 @@ +require 'socket' + module Propono class PublisherError < ProponoError end class Publisher @@ -33,9 +35,19 @@ end def publish_via_udp payload = {topic: topic_id, message: message}.to_json UDPSocket.new.send(payload, 0, Propono.config.udp_host, Propono.config.udp_port) + rescue => e + Propono.config.logger.error "Propono failed to send : #{e}" + end + + def publish_via_tcp + payload = {topic: topic_id, message: message}.to_json + + socket = TCPSocket.new(Propono.config.tcp_host, Propono.config.tcp_port) + socket.write payload + socket.close rescue => e Propono.config.logger.error "Propono failed to send : #{e}" end end end