class SPSSubPing
Public Class Methods
new(port: '59000', host: nil, address: nil, topic: 'system/watchdog/ping', identifier: nil)
click to toggle source
Calls superclass method
# File lib/sps-sub-ping.rb, line 12 def initialize(port: '59000', host: nil, address: nil, topic: 'system/watchdog/ping', identifier: nil) raise 'SPSSubPing: identifier must be provided' unless identifier @host = host || address || 'localhost' @port = port.to_s @topic, @identifier = topic, identifier super(host: @host, port: port) @pub = SPSPub.new address: host, port: port end
Public Instance Methods
onmessage(msg)
click to toggle source
# File lib/sps-sub-ping.rb, line 31 def onmessage(msg) @pub.notice @topic.sub(/ping$/,'pong') + ": #{@identifier} responded" end
start()
click to toggle source
# File lib/sps-sub-ping.rb, line 27 def start() subscribe(topic: @topic) end