wamp-client 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/wamp/client.rb +2 -2
- data/lib/wamp/client/version.rb +1 -1
- data/test/support/wamp_server.py +3 -1
- data/test/unit/client_spec.rb +33 -33
- metadata +4 -4
data/lib/wamp/client.rb
CHANGED
@@ -18,8 +18,8 @@ module WAMP
|
|
18
18
|
TYPEID_EVENT = 8
|
19
19
|
|
20
20
|
|
21
|
-
def initialize(uri, options=
|
22
|
-
options
|
21
|
+
def initialize(uri, options={})
|
22
|
+
options = {:subprotocols => ["wamp"]}.merge(options)
|
23
23
|
@session_id = nil
|
24
24
|
@ws = Net::WS.new(uri, options)
|
25
25
|
@subscriptions = {}
|
data/lib/wamp/client/version.rb
CHANGED
data/test/support/wamp_server.py
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
#!/usr/bin/env python2.7 -u -Wall
|
2
|
+
|
1
3
|
import sys
|
2
4
|
|
3
5
|
from twisted.internet import reactor
|
@@ -18,7 +20,7 @@ class RpcServerProtocol(WampServerProtocol):
|
|
18
20
|
|
19
21
|
if __name__ == '__main__':
|
20
22
|
factory = WampServerFactory("ws://localhost:9001", debug=True)
|
21
|
-
factory.protocol =
|
23
|
+
factory.protocol = WampServerProtocol
|
22
24
|
log.startLogging(sys.stdout)
|
23
25
|
listenWS(factory)
|
24
26
|
print "Here we go"
|
data/test/unit/client_spec.rb
CHANGED
@@ -9,49 +9,48 @@ describe WAMP::Client do
|
|
9
9
|
def with_echo_server(&block)
|
10
10
|
echo_server_path = File.expand_path("../support/echo_server.py",
|
11
11
|
File.dirname(__FILE__))
|
12
|
+
wamp_server_path = File.expand_path("../support/wamp_server.py",
|
13
|
+
File.dirname(__FILE__))
|
12
14
|
|
13
|
-
|
15
|
+
puts "bringing up echo server"
|
16
|
+
Open3.popen3(wamp_server_path) do |stdin, stdout, stderr, wait_thr|
|
17
|
+
pid = wait_thr.pid
|
14
18
|
stdout.readline # the readline tells us the server is up
|
15
|
-
|
19
|
+
block.call("localhost", 9001)
|
20
|
+
puts "tearing down echo server"
|
21
|
+
Process.kill("TERM", pid)
|
16
22
|
end
|
17
23
|
end
|
18
24
|
|
19
|
-
# it "should be sane" do
|
20
|
-
# true.must_equal true
|
21
|
-
# end
|
22
|
-
|
23
25
|
it "can send and receive message" do
|
24
26
|
CHANNEL = "/mpd/test"
|
25
27
|
|
26
28
|
host = "localhost"; port = 9001
|
29
|
+
with_echo_server do |host, port|
|
30
|
+
listener = WAMP::Client.new("ws://#{host}:#{port}")
|
31
|
+
listener.open
|
32
|
+
listener.subscribe(CHANNEL, proc {|x| $stderr.puts "Rx: %p" % [x]})
|
27
33
|
|
28
|
-
|
29
|
-
:subprotocols => ["wamp"])
|
30
|
-
listener.open
|
31
|
-
listener.subscribe(CHANNEL, proc {|x| $stderr.puts "Rx: %p" % [x]})
|
34
|
+
puts "listener subscribed"
|
32
35
|
|
33
|
-
puts "listener subscribed"
|
34
36
|
|
37
|
+
client = WAMP::Client.new("ws://#{host}:#{port}").tap {|x| x.open}
|
38
|
+
client.publish(CHANNEL, "testing 1 2 3")
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
puts client.open
|
39
|
-
client.publish(CHANNEL, "testing 1 2 3")
|
40
|
+
puts "checking..."
|
41
|
+
listener.check(0.1)
|
40
42
|
|
41
|
-
|
42
|
-
listener.check(0.1)
|
43
|
+
client.publish(CHANNEL, "∆AIMON")
|
43
44
|
|
44
|
-
|
45
|
+
puts "checking..."
|
46
|
+
listener.check(0.1)
|
45
47
|
|
46
|
-
|
47
|
-
listener.check(0.1)
|
48
|
+
client.publish(CHANNEL, {"file" => "∆AIMON"})
|
48
49
|
|
49
|
-
|
50
|
+
puts "checking..."
|
51
|
+
listener.check(0.1)
|
50
52
|
|
51
|
-
|
52
|
-
listener.check(0.1)
|
53
|
-
|
54
|
-
config = StringIO.new <<EOF
|
53
|
+
config = StringIO.new <<EOF
|
55
54
|
development:
|
56
55
|
hostname: admin@localhost
|
57
56
|
port: 6601
|
@@ -61,16 +60,17 @@ test:
|
|
61
60
|
port: 6601
|
62
61
|
EOF
|
63
62
|
|
64
|
-
|
65
|
-
|
66
|
-
|
63
|
+
rmpd = Rmpd::Connection.new(config)
|
64
|
+
pi = rmpd.search("artist", "aimon", "title", "current")
|
65
|
+
client.publish(CHANNEL, pi)
|
67
66
|
|
68
|
-
|
69
|
-
|
67
|
+
puts "checking..."
|
68
|
+
listener.check(0.1)
|
70
69
|
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
puts "closing"
|
71
|
+
client.close
|
72
|
+
listener.close
|
73
|
+
end
|
74
74
|
|
75
75
|
end
|
76
76
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wamp-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yajl-ruby
|
@@ -171,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
171
|
version: '0'
|
172
172
|
segments:
|
173
173
|
- 0
|
174
|
-
hash:
|
174
|
+
hash: -4201952591777948766
|
175
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
176
|
none: false
|
177
177
|
requirements:
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: '0'
|
181
181
|
segments:
|
182
182
|
- 0
|
183
|
-
hash:
|
183
|
+
hash: -4201952591777948766
|
184
184
|
requirements: []
|
185
185
|
rubyforge_project:
|
186
186
|
rubygems_version: 1.8.23
|