Class: Holoserve::Interface::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/holoserve/interface/event.rb

Class Method Summary collapse

Instance Method Summary collapse

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)
  send_message "bucket:#{JSON.dump(request)}"
end

.send_message(text) ⇒ Object



33
34
35
36
# File 'lib/holoserve/interface/event.rb', line 33

def self.send_message(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)
  send_message "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 on_message(environment, message)
  environment.logger.info "MESSAGE #{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