Class: ForeignOffice::Busses::PubnubBus
Class Method Summary
collapse
Methods inherited from GenericBus
flush_messages, published_messages
Class Method Details
.config(config) ⇒ Object
3
4
5
6
7
|
# File 'lib/foreign_office/busses/pubnub_bus.rb', line 3
def self.config(config)
self.publish_key = config[:publish_key]
self.subscribe_key = config[:subscribe_key]
self.secret_key = config[:secret_key]
end
|
.connection ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/foreign_office/busses/pubnub_bus.rb', line 33
def self.connection
@pubnub ||= ::Pubnub.new(
publish_key: self.publish_key, subscribe_key: self.subscribe_key, secret_key: self.secret_key,
ssl: true
)
end
|
.publish(message) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/foreign_office/busses/pubnub_bus.rb', line 42
def self.publish(message)
channel = message[:channel]
if browser_tab_id = message[:browser_tab_id]
channel += "@#{browser_tab_id}"
end
self.connection.publish(
channel: channel,
message: message,
http_sync: true
) do |envelope|
if '200' != envelope.status_code.to_s
Rails.logger.error "ForeignOffice error esponse:"
Rails.logger.error envelope.message
Rails.logger.error envelope.channel
Rails.logger.error envelope.status_code
Rails.logger.error envelope.timetoken
end
end
end
|
.publish_key ⇒ Object
13
14
15
|
# File 'lib/foreign_office/busses/pubnub_bus.rb', line 13
def self.publish_key
@publish_key
end
|
.publish_key=(publish_key) ⇒ Object
9
10
11
|
# File 'lib/foreign_office/busses/pubnub_bus.rb', line 9
def self.publish_key=(publish_key)
@publish_key = publish_key
end
|
.secret_key ⇒ Object
29
30
31
|
# File 'lib/foreign_office/busses/pubnub_bus.rb', line 29
def self.secret_key
@secret_key
end
|
.secret_key=(secret_key) ⇒ Object
25
26
27
|
# File 'lib/foreign_office/busses/pubnub_bus.rb', line 25
def self.secret_key=(secret_key)
@secret_key = secret_key
end
|
.subscribe_key ⇒ Object
21
22
23
|
# File 'lib/foreign_office/busses/pubnub_bus.rb', line 21
def self.subscribe_key
@subscribe_key
end
|
.subscribe_key=(subscribe_key) ⇒ Object
17
18
19
|
# File 'lib/foreign_office/busses/pubnub_bus.rb', line 17
def self.subscribe_key=(subscribe_key)
@subscribe_key = subscribe_key
end
|