ddp-server 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ddp/server/protocol/data.rb +11 -11
- data/lib/ddp/server/protocol/rpc.rb +17 -11
- data/lib/ddp/server/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5321d037bf5da044192560738c9bad091acde4b7
|
4
|
+
data.tar.gz: a2898c62564467a37ef8f4bc090c981d00c67fbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 953c4d98aee48c9708223c2b9664dfe0ada3e5e2a85a02dac5d25620cafd67a7029908c1fa82eaf4b21a7b06cb6e39306b5f83fa3e10346fc7558ac88b1e4580
|
7
|
+
data.tar.gz: ca9e0fb1e9f42f73291c3dab6d9b968f25daae2b6094a18cc39272b756f1aae1c837dd6b27c9b53a1f62e5dfe245f7e21ef58926d47e3796a6cbdb6f48b2f723
|
@@ -6,58 +6,58 @@ module DDP
|
|
6
6
|
def handle_data
|
7
7
|
case @message['msg']
|
8
8
|
when 'sub'
|
9
|
-
handle_sub
|
9
|
+
handle_sub(@message['id'], @message['name'], @message['params'])
|
10
10
|
true
|
11
11
|
when 'unsub'
|
12
|
-
handle_unsub
|
12
|
+
handle_unsub(@message['id'])
|
13
13
|
true
|
14
14
|
else
|
15
15
|
false
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
def handle_sub
|
19
|
+
def handle_sub(_id, _name, _params)
|
20
20
|
raise 'Must be overridden'
|
21
21
|
end
|
22
22
|
|
23
|
-
def handle_unsub
|
23
|
+
def handle_unsub(_id)
|
24
24
|
raise 'Must be overridden'
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def send_nosub(id, error = nil)
|
28
28
|
message = { msg: 'nosub', id: id }
|
29
29
|
message.merge!(error: error) if error
|
30
30
|
write_message message
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
33
|
+
def send_added(collection, id, fields = nil)
|
34
34
|
message = { msg: 'added', id: id, collection: collection }
|
35
35
|
message.merge!(fields: fields) if fields
|
36
36
|
write_message message
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
39
|
+
def send_changed(collection, id, fields = nil, cleared = nil)
|
40
40
|
message = { msg: 'changed', id: id, collection: collection }
|
41
41
|
message.merge!(fields: fields) if fields
|
42
42
|
message.merge!(cleared: cleared) if cleared
|
43
43
|
write_message message
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def send_removed(collection, id)
|
47
47
|
write_message msg: 'removed', collection: collection, id: id
|
48
48
|
end
|
49
49
|
|
50
|
-
def
|
50
|
+
def send_ready(subs)
|
51
51
|
write_message msg: 'ready', subs: subs
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
54
|
+
def send_added_before(collection, id, fields = nil, before = nil)
|
55
55
|
message = { msg: 'addedBefore', id: id, collection: collection, before: before }
|
56
56
|
message.merge!(fields: fields) if fields
|
57
57
|
write_message message
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
60
|
+
def send_moved_before(collection, id, before = nil)
|
61
61
|
write_message msg: 'movedBefore', id: id, collection: collection, before: before
|
62
62
|
end
|
63
63
|
end
|
@@ -3,33 +3,39 @@ module DDP
|
|
3
3
|
module Protocol
|
4
4
|
# Protocol regarding remote procedure calls
|
5
5
|
module RPC
|
6
|
+
NO_RESULT = Object.new
|
7
|
+
|
6
8
|
def handle_rpc
|
7
9
|
case @message['msg']
|
8
10
|
when 'method'
|
9
|
-
handle_method
|
11
|
+
handle_method(@message['id'], @message['method'], @message['params'])
|
10
12
|
true
|
11
13
|
else
|
12
14
|
false
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
def handle_method
|
18
|
+
def handle_method(_id, _method, _params)
|
17
19
|
raise 'Must be overridden'
|
18
20
|
end
|
19
21
|
|
20
|
-
def
|
22
|
+
def send_result(id, result = NO_RESULT)
|
21
23
|
message = { msg: 'result', id: id }
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
message['result'] = result unless result == NO_RESULT
|
25
|
+
write_message(message)
|
26
|
+
end
|
27
|
+
|
28
|
+
def send_error_result(id, error)
|
29
|
+
message = { msg: 'result', id: id }
|
30
|
+
message['error'] = {
|
31
|
+
error: error.class.name,
|
32
|
+
reason: error.message,
|
33
|
+
details: "Backtrace: \n#{error.backtrace.join("\n")}"
|
34
|
+
}
|
29
35
|
write_message(message)
|
30
36
|
end
|
31
37
|
|
32
|
-
def
|
38
|
+
def send_updated(methods)
|
33
39
|
write_message msg: 'updated', methods: methods
|
34
40
|
end
|
35
41
|
end
|
data/lib/ddp/server/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ddp-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tinco Andringa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|