Class: SPSPub
- Inherits:
-
Object
- Object
- SPSPub
- Defined in:
- lib/sps-pub.rb
Class Method Summary collapse
- .notice(s, host = 'sps', address: host, port: '59000', retries: 3) ⇒ Object
- .pub(s, address: 'sps', port: '59000') ⇒ Object
- .publish(s, address: 'sps', port: '59000') ⇒ Object
Instance Method Summary collapse
-
#initialize(address: 'sps', port: '59000') ⇒ SPSPub
constructor
A new instance of SPSPub.
- #notice(s) ⇒ Object
- #publish ⇒ Object
Constructor Details
#initialize(address: 'sps', port: '59000') ⇒ SPSPub
Returns a new instance of SPSPub.
10 11 12 |
# File 'lib/sps-pub.rb', line 10 def initialize(address: 'sps', port: '59000') @client = Net::WS.new "ws://%s:%s/" % [address, port] end |
Class Method Details
.notice(s, host = 'sps', address: host, port: '59000', retries: 3) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sps-pub.rb', line 20 def self.notice(s, host='sps', address: host, port: '59000', retries: 3) retry_attempts = 0 client = Net::WS.new "ws://%s:%s/" % [host, port] begin client.send s rescue Errno::ETIMEDOUT => e if retries and retry_attempts < retries then retries += 1 puts 'SPSPub timeout retrying ...' retry else puts 'SPSPub timeout while trying to contact the host' end end :message_sent end |
.pub(s, address: 'sps', port: '59000') ⇒ Object
47 48 49 |
# File 'lib/sps-pub.rb', line 47 def self.pub(s, address: 'sps', port: '59000') self.notice(s, address: 'sps', port: '59000') end |
.publish(s, address: 'sps', port: '59000') ⇒ Object
51 52 53 |
# File 'lib/sps-pub.rb', line 51 def self.publish(s, address: 'sps', port: '59000') self.notice(s, address: 'sps', port: '59000') end |
Instance Method Details
#notice(s) ⇒ Object
14 15 16 |
# File 'lib/sps-pub.rb', line 14 def notice(s) @client.send s end |
#publish ⇒ Object
18 19 20 |
# File 'lib/sps-pub.rb', line 18 def notice(s) @client.send s end |