Please disable Adblockers and enable JavaScript for domain CEWebS.cs.univie.ac.at! We have NO ADS, but they may interfere with some of our course material.
Name: tests/vote.rb
1: | #!/usr/bin/ruby |
2: | require 'riddl/client' |
3: | require 'pp' |
4: | |
5: | srv = Riddl::Client.new('http://localhost:9302','http://localhost:9302/?riddl-description') |
6: | res = srv.resource("/Virtual%20Business%201/notifications/subscriptions/") |
7: | status, response = res.post [ |
8: | Riddl::Parameter::Simple.new("topic","task"), |
9: | Riddl::Parameter::Simple.new("votes","add"), |
10: | ] |
11: | sub = response[0].value |
12: | |
13: | view = srv.resource("/Virtual%20Business%201/notifications/subscriptions/#{sub}/ws/") |
14: | view.ws do |conn| |
15: | conn.stream do |msg| |
16: | pp msg.to_s |
17: | p '========' |
18: | doc = XML::Smart::string(msg.to_s) |
19: | cb = doc.find('string(/vote/callback)') |
20: | conn.send_msg "<vote id='#{cb}'>stertzf9</vote>" |
21: | end |
22: | conn.disconnect do |
23: | EM::stop_event_loop |
24: | end |
25: | end |