Class: Scales::Monitor::WebSocket

Inherits:
Goliath::WebSocket
  • Object
show all
Defined in:
lib/scales-monitor/web_socket.rb

Instance Method Summary collapse

Instance Method Details

#on_close(env) ⇒ Object



20
21
22
# File 'lib/scales-monitor/web_socket.rb', line 20

def on_close(env)
  remove_from_subscribers(env) if env['REQUEST_PATH'] == "/socket"
end

#on_error(env, error) ⇒ Object



13
14
15
# File 'lib/scales-monitor/web_socket.rb', line 13

def on_error(env, error)
  env.logger.error error
end

#on_message(env, msg) ⇒ Object



17
18
# File 'lib/scales-monitor/web_socket.rb', line 17

def on_message(env, msg)
end

#on_open(env) ⇒ Object



7
8
9
10
11
# File 'lib/scales-monitor/web_socket.rb', line 7

def on_open(env)
  send_initial_statuses(env)
  setup_subscription!
  add_to_subscribers(env)
end

#response(env) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/scales-monitor/web_socket.rb', line 24

def response(env)
  path = env['REQUEST_PATH']
  
  if path == '/socket'
    super(env)
  else
    [200, {}, Monitor.serve(path)]
  end
end