Class: Lolitra::FayeBus
- Inherits:
-
Object
- Object
- Lolitra::FayeBus
- Defined in:
- lib/lolitra/handler_base.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ FayeBus
constructor
A new instance of FayeBus.
- #publish(message) ⇒ Object
- #subscribe(message_class, handler_class) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ FayeBus
Returns a new instance of FayeBus.
273 274 275 276 277 |
# File 'lib/lolitra/handler_base.rb', line 273 def initialize( = {}) EM::next_tick do @socketClient = Faye::Client.new([:url] || 'http://localhost:9292/faye') end end |
Instance Method Details
#publish(message) ⇒ Object
289 290 291 |
# File 'lib/lolitra/handler_base.rb', line 289 def publish() @socketClient.publish(.class., .marshall) end |
#subscribe(message_class, handler_class) ⇒ Object
279 280 281 282 283 284 285 286 287 |
# File 'lib/lolitra/handler_base.rb', line 279 def subscribe(, handler_class) EM::next_tick do @socketClient.subscribe(.) do |payload| Lolitra::logger.debug("Message recived:") Lolitra::logger.debug("#{payload}") handler_class.handle(.unmarshall(payload)) end end end |