wamp 0.0.0 → 0.0.1
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/Gemfile +3 -1
- data/Gemfile.lock +7 -1
- data/VERSION +1 -1
- data/demo/client.html +8 -3
- data/demo/client.js +24 -24
- data/demo/client.rb +29 -0
- data/lib/wamp.rb +11 -0
- data/lib/wamp/bindable.rb +16 -0
- data/lib/wamp/client.rb +118 -0
- data/lib/wamp/engines/memory.rb +104 -0
- data/lib/wamp/protocols/version_1.rb +128 -0
- data/lib/wamp/server.rb +57 -80
- data/lib/wamp/socket.rb +3 -4
- data/lib/wamp/topic.rb +32 -3
- data/spec/lib/wamp/client_spec.rb +9 -0
- data/spec/lib/wamp/engines/memory_spec.rb +118 -0
- data/spec/lib/wamp/protocols/version_1_spec.rb +80 -0
- data/spec/lib/wamp/server_spec.rb +5 -6
- data/spec/lib/wamp/socket_spec.rb +6 -6
- data/spec/lib/wamp/topic_spec.rb +1 -1
- data/spec/support/dummy_socket.rb +11 -0
- data/wamp.gemspec +20 -5
- metadata +49 -8
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe WAMP::Protocols::Version1 do
|
4
|
+
let(:protocol) { WAMP::Protocols::Version1.new }
|
5
|
+
|
6
|
+
it "should have a version of 1" do
|
7
|
+
expect(protocol.version).to eq 1
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should describe a WELCOME message" do
|
11
|
+
expect(protocol.welcome "id").to eq "[0,\"id\",1,\"#{WAMP.identity}\"]"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should describe a PREFIX message" do
|
15
|
+
expect(protocol.prefix "prefix", "uri").to eq "[1,\"prefix\",\"uri\"]"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should describe a CALL message" do
|
19
|
+
expect(protocol.call "callID", "procURI", [1, 2], "Arg3")
|
20
|
+
.to eq "[2,\"callID\",\"procURI\",[1,2],\"Arg3\"]"
|
21
|
+
end
|
22
|
+
|
23
|
+
context "#call_result" do
|
24
|
+
it "should describe a CALLRESULT with null as default results" do
|
25
|
+
expect(protocol.call_result "callID").to eq "[3,\"callID\",null]"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should describe a CALLRESULT with a given result" do
|
29
|
+
expect(protocol.call_result "callID", "Result").to eq "[3,\"callID\",\"Result\"]"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "#call_error" do
|
34
|
+
it "should describe a CALLERROR message without error details" do
|
35
|
+
expect(protocol.call_error "callID", "errorURI", "errorDesc")
|
36
|
+
.to eq "[4,\"callID\",\"errorURI\",\"errorDesc\"]"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should describe a CALLERROR message with error details" do
|
40
|
+
expect(protocol.call_error "callID", "errorURI", "errorDesc", "errorDetails")
|
41
|
+
.to eq "[4,\"callID\",\"errorURI\",\"errorDesc\",\"errorDetails\"]"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "#subscribe" do
|
46
|
+
it "should describe the SUBSCRIBE message" do
|
47
|
+
expect(protocol.subscribe "topicURI").to eq "[5,\"topicURI\"]"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "#unsubscribe" do
|
52
|
+
it "should describe the UNSUBSCRIBE message" do
|
53
|
+
expect(protocol.unsubscribe "topicURI").to eq "[6,\"topicURI\"]"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "#publish" do
|
58
|
+
it "should describe the PUBLISH message with a topic and a event payload" do
|
59
|
+
expect(protocol.publish "topic_uri", "payload")
|
60
|
+
.to eq "[7,\"topic_uri\",\"payload\"]"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should describe the PUBLISH message with a topic, event payload, and excludeMe" do
|
64
|
+
expect(protocol.publish "topic_uri", "payload", true)
|
65
|
+
.to eq "[7,\"topic_uri\",\"payload\",true]"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should describe the PUBLISH message with a topic, event payload, exclude, and include" do
|
69
|
+
expect(protocol.publish "topic_uri", "payload", nil, ["include_id"])
|
70
|
+
.to eq "[7,\"topic_uri\",\"payload\",null,[\"include_id\"]]"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "#event" do
|
75
|
+
it "should describe the EVENT message" do
|
76
|
+
expect(protocol.event "topicURI", "Event Data")
|
77
|
+
.to eq "[8,\"topicURI\",\"Event Data\"]"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -2,16 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe WAMP::Server do
|
4
4
|
let(:server) { WAMP::Server.new(host: "localhost", port: 9292) }
|
5
|
+
let(:dummy_socket) { DummySocket.new }
|
5
6
|
|
6
7
|
context "initilization" do
|
7
8
|
it "should accept a hash of options" do
|
8
9
|
expect(server.options).to eq({ host: "localhost", port: 9292 })
|
9
10
|
end
|
10
11
|
|
11
|
-
it "should have an empty hash of sockets" do
|
12
|
-
expect(server.sockets).to eq({})
|
13
|
-
end
|
14
|
-
|
15
12
|
it "should have an empty hash of topics" do
|
16
13
|
expect(server.topics).to eq({})
|
17
14
|
end
|
@@ -23,11 +20,13 @@ describe WAMP::Server do
|
|
23
20
|
|
24
21
|
context "bind" do
|
25
22
|
it "should bind a subscribe callback do" do
|
26
|
-
expect { server.bind(:subscribe) { |client_id, topic| } }
|
23
|
+
expect { server.bind(:subscribe) { |client_id, topic| } }
|
24
|
+
.to_not raise_error ""
|
27
25
|
end
|
28
26
|
|
29
27
|
it "should raise an error if an invalid binding name is given" do
|
30
|
-
expect { server.bind(:invalid) {} }
|
28
|
+
expect { server.bind(:invalid) {} }
|
29
|
+
.to raise_error "Invalid binding: invalid"
|
31
30
|
end
|
32
31
|
end
|
33
32
|
end
|
@@ -5,7 +5,7 @@ class DummySocket
|
|
5
5
|
end
|
6
6
|
|
7
7
|
describe WAMP::Socket do
|
8
|
-
let(:new_socket) { WAMP::Socket.new(DummySocket.new) }
|
8
|
+
let(:new_socket) { WAMP::Socket.new("sampleid", DummySocket.new) }
|
9
9
|
|
10
10
|
context "#initialization" do
|
11
11
|
it "should return a client" do
|
@@ -20,11 +20,11 @@ describe WAMP::Socket do
|
|
20
20
|
expect(new_socket.topics).to eq []
|
21
21
|
end
|
22
22
|
|
23
|
-
it "should send the welcome message" do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
23
|
+
# it "should send the welcome message" do
|
24
|
+
# ds = DummySocket.new
|
25
|
+
# ds.should_receive :send
|
26
|
+
# WAMP::Socket.new("sampleid", ds)
|
27
|
+
# end
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should add a new topic to client' do
|
data/spec/lib/wamp/topic_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe WAMP::Topic do
|
|
4
4
|
context "initialization" do
|
5
5
|
it "should have a URI" do
|
6
6
|
topic = WAMP::Topic.new("ws://localhost:9292/sample_topic")
|
7
|
-
expect(topic.
|
7
|
+
expect(topic.uri).to eq "ws://localhost:9292/sample_topic"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
data/wamp.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "wamp"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brady Love"]
|
12
|
-
s.date = "2013-04-
|
12
|
+
s.date = "2013-04-15"
|
13
13
|
s.description = "A Ruby implementation of the WAMP (Web Application Messaging Protocol) WebSocket subprotocol"
|
14
14
|
s.email = "love.brady@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,18 +29,27 @@ Gem::Specification.new do |s|
|
|
29
29
|
"demo/app.rb",
|
30
30
|
"demo/client.html",
|
31
31
|
"demo/client.js",
|
32
|
+
"demo/client.rb",
|
32
33
|
"demo/config.ru",
|
33
34
|
"lib/wamp.rb",
|
35
|
+
"lib/wamp/bindable.rb",
|
36
|
+
"lib/wamp/client.rb",
|
37
|
+
"lib/wamp/engines/memory.rb",
|
34
38
|
"lib/wamp/message_type.rb",
|
39
|
+
"lib/wamp/protocols/version_1.rb",
|
35
40
|
"lib/wamp/server.rb",
|
36
41
|
"lib/wamp/socket.rb",
|
37
42
|
"lib/wamp/topic.rb",
|
43
|
+
"spec/lib/wamp/client_spec.rb",
|
44
|
+
"spec/lib/wamp/engines/memory_spec.rb",
|
38
45
|
"spec/lib/wamp/message_type_spec.rb",
|
46
|
+
"spec/lib/wamp/protocols/version_1_spec.rb",
|
39
47
|
"spec/lib/wamp/server_spec.rb",
|
40
48
|
"spec/lib/wamp/socket_spec.rb",
|
41
49
|
"spec/lib/wamp/topic_spec.rb",
|
42
50
|
"spec/lib/wamp_spec.rb",
|
43
51
|
"spec/spec_helper.rb",
|
52
|
+
"spec/support/dummy_socket.rb",
|
44
53
|
"wamp.gemspec"
|
45
54
|
]
|
46
55
|
s.homepage = "http://github.com/bradylove/wamp-ruby"
|
@@ -57,10 +66,12 @@ Gem::Specification.new do |s|
|
|
57
66
|
s.add_runtime_dependency(%q<faye-websocket>, [">= 0"])
|
58
67
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
59
68
|
s.add_development_dependency(%q<guard-rspec>, [">= 0"])
|
69
|
+
s.add_development_dependency(%q<pry-nav>, [">= 0"])
|
60
70
|
s.add_development_dependency(%q<rb-fsevent>, [">= 0"])
|
61
71
|
s.add_development_dependency(%q<rb-inotify>, [">= 0"])
|
62
72
|
s.add_development_dependency(%q<fuubar>, [">= 0"])
|
63
|
-
s.add_development_dependency(%q<
|
73
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
74
|
+
s.add_development_dependency(%q<redcarpet>, [">= 0"])
|
64
75
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
65
76
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
66
77
|
else
|
@@ -68,10 +79,12 @@ Gem::Specification.new do |s|
|
|
68
79
|
s.add_dependency(%q<faye-websocket>, [">= 0"])
|
69
80
|
s.add_dependency(%q<rspec>, [">= 0"])
|
70
81
|
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
82
|
+
s.add_dependency(%q<pry-nav>, [">= 0"])
|
71
83
|
s.add_dependency(%q<rb-fsevent>, [">= 0"])
|
72
84
|
s.add_dependency(%q<rb-inotify>, [">= 0"])
|
73
85
|
s.add_dependency(%q<fuubar>, [">= 0"])
|
74
|
-
s.add_dependency(%q<
|
86
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
87
|
+
s.add_dependency(%q<redcarpet>, [">= 0"])
|
75
88
|
s.add_dependency(%q<bundler>, [">= 0"])
|
76
89
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
77
90
|
end
|
@@ -80,10 +93,12 @@ Gem::Specification.new do |s|
|
|
80
93
|
s.add_dependency(%q<faye-websocket>, [">= 0"])
|
81
94
|
s.add_dependency(%q<rspec>, [">= 0"])
|
82
95
|
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
96
|
+
s.add_dependency(%q<pry-nav>, [">= 0"])
|
83
97
|
s.add_dependency(%q<rb-fsevent>, [">= 0"])
|
84
98
|
s.add_dependency(%q<rb-inotify>, [">= 0"])
|
85
99
|
s.add_dependency(%q<fuubar>, [">= 0"])
|
86
|
-
s.add_dependency(%q<
|
100
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
101
|
+
s.add_dependency(%q<redcarpet>, [">= 0"])
|
87
102
|
s.add_dependency(%q<bundler>, [">= 0"])
|
88
103
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
89
104
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wamp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
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-04-
|
12
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thin
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: pry-nav
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: rb-fsevent
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,21 +140,37 @@ dependencies:
|
|
124
140
|
- !ruby/object:Gem::Version
|
125
141
|
version: '0'
|
126
142
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
143
|
+
name: yard
|
128
144
|
requirement: !ruby/object:Gem::Requirement
|
129
145
|
none: false
|
130
146
|
requirements:
|
131
|
-
- -
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: redcarpet
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
132
164
|
- !ruby/object:Gem::Version
|
133
|
-
version: '
|
165
|
+
version: '0'
|
134
166
|
type: :development
|
135
167
|
prerelease: false
|
136
168
|
version_requirements: !ruby/object:Gem::Requirement
|
137
169
|
none: false
|
138
170
|
requirements:
|
139
|
-
- -
|
171
|
+
- - ! '>='
|
140
172
|
- !ruby/object:Gem::Version
|
141
|
-
version: '
|
173
|
+
version: '0'
|
142
174
|
- !ruby/object:Gem::Dependency
|
143
175
|
name: bundler
|
144
176
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,18 +224,27 @@ files:
|
|
192
224
|
- demo/app.rb
|
193
225
|
- demo/client.html
|
194
226
|
- demo/client.js
|
227
|
+
- demo/client.rb
|
195
228
|
- demo/config.ru
|
196
229
|
- lib/wamp.rb
|
230
|
+
- lib/wamp/bindable.rb
|
231
|
+
- lib/wamp/client.rb
|
232
|
+
- lib/wamp/engines/memory.rb
|
197
233
|
- lib/wamp/message_type.rb
|
234
|
+
- lib/wamp/protocols/version_1.rb
|
198
235
|
- lib/wamp/server.rb
|
199
236
|
- lib/wamp/socket.rb
|
200
237
|
- lib/wamp/topic.rb
|
238
|
+
- spec/lib/wamp/client_spec.rb
|
239
|
+
- spec/lib/wamp/engines/memory_spec.rb
|
201
240
|
- spec/lib/wamp/message_type_spec.rb
|
241
|
+
- spec/lib/wamp/protocols/version_1_spec.rb
|
202
242
|
- spec/lib/wamp/server_spec.rb
|
203
243
|
- spec/lib/wamp/socket_spec.rb
|
204
244
|
- spec/lib/wamp/topic_spec.rb
|
205
245
|
- spec/lib/wamp_spec.rb
|
206
246
|
- spec/spec_helper.rb
|
247
|
+
- spec/support/dummy_socket.rb
|
207
248
|
- wamp.gemspec
|
208
249
|
homepage: http://github.com/bradylove/wamp-ruby
|
209
250
|
licenses:
|
@@ -220,7 +261,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
261
|
version: '0'
|
221
262
|
segments:
|
222
263
|
- 0
|
223
|
-
hash:
|
264
|
+
hash: 2829213371230437822
|
224
265
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
266
|
none: false
|
226
267
|
requirements:
|