Class: Holoserve::Interface::Event
- Inherits:
-
Object
- Object
- Holoserve::Interface::Event
- Defined in:
- lib/holoserve/interface/event.rb
Class Method Summary collapse
- .handler=(value) ⇒ Object
- .send_bucket_event(request) ⇒ Object
- .send_message(text) ⇒ Object
- .send_pair_event(id) ⇒ Object
Instance Method Summary collapse
- #on_close(environment) ⇒ Object
- #on_error(environment, error) ⇒ Object
- #on_message(environment, message) ⇒ Object
- #on_open(environment) ⇒ Object
Class Method Details
.handler=(value) ⇒ Object
21 22 23 |
# File 'lib/holoserve/interface/event.rb', line 21 def self.handler=(value) @handler = value end |
.send_bucket_event(request) ⇒ Object
29 30 31 |
# File 'lib/holoserve/interface/event.rb', line 29 def self.send_bucket_event(request) "bucket:#{JSON.dump(request)}" end |
.send_message(text) ⇒ Object
33 34 35 36 |
# File 'lib/holoserve/interface/event.rb', line 33 def self.(text) return unless @handler @handler.send_text_frame text end |
.send_pair_event(id) ⇒ Object
25 26 27 |
# File 'lib/holoserve/interface/event.rb', line 25 def self.send_pair_event(id) "pair:#{id}" end |
Instance Method Details
#on_close(environment) ⇒ Object
13 14 15 |
# File 'lib/holoserve/interface/event.rb', line 13 def on_close(environment) environment.logger.info("WS CLOSED") end |
#on_error(environment, error) ⇒ Object
17 18 19 |
# File 'lib/holoserve/interface/event.rb', line 17 def on_error(environment, error) environment.logger.error error end |
#on_message(environment, message) ⇒ Object
9 10 11 |
# File 'lib/holoserve/interface/event.rb', line 9 def (environment, ) environment.logger.info "MESSAGE #{}" end |
#on_open(environment) ⇒ Object
5 6 7 |
# File 'lib/holoserve/interface/event.rb', line 5 def on_open(environment) self.class.handler = environment["handler"] end |