Class: NotificationsHandler
- Inherits:
-
Riddl::Utils::Notifications::Producer::HandlerBase
- Object
- Riddl::Utils::Notifications::Producer::HandlerBase
- NotificationsHandler
- Defined in:
- lib/cpee/handler_notifications.rb
Overview
This file is part of CPEE.
CPEE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
CPEE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with CPEE (file COPYING in the main directory). If not, see <www.gnu.org/licenses/>.
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #update ⇒ Object
- #ws_close ⇒ Object
- #ws_message(data) ⇒ Object
- #ws_open(socket) ⇒ Object
Instance Method Details
#create ⇒ Object
35 36 37 38 |
# File 'lib/cpee/handler_notifications.rb', line 35 def create @data.unserialize_notifications!(:cre,@key) @data.notify('handler/change', :instance => @data.instance) end |
#delete ⇒ Object
39 40 41 42 |
# File 'lib/cpee/handler_notifications.rb', line 39 def delete @data.unserialize_notifications!(:del,@key) @data.notify('handler/change', :instance => @data.instance) end |
#update ⇒ Object
43 44 45 46 |
# File 'lib/cpee/handler_notifications.rb', line 43 def update @data.unserialize_notifications!(:upd,@key) @data.notify('handler/change', :instance => @data.instance) end |
#ws_close ⇒ Object
19 20 21 22 |
# File 'lib/cpee/handler_notifications.rb', line 19 def ws_close @data.unserialize_notifications!(:del,@key) @data.notify('handler/change', :instance => @data.instance) end |
#ws_message(data) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cpee/handler_notifications.rb', line 23 def (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 |
#ws_open(socket) ⇒ Object
16 17 18 |
# File 'lib/cpee/handler_notifications.rb', line 16 def ws_open(socket) @data.add_websocket(@key,socket) end |