Method: NotificationsHandler#ws_message

Defined in:
lib/cpee/handler_notifications.rb

#ws_message(data) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cpee/handler_notifications.rb', line 23

def ws_message(data)
  begin
    doc = XML::Smart::string(data)
    callback = doc.find("string(/vote/@id)")
    result = doc.find("string(/vote)")
    @data.callbacks[callback].callback(result == 'true' ? true : false)
    @data.callbacks.delete(callback)
  rescue
    puts "Invalid message over websocket"
  end
end