easy_wamp 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/lib/easy_wamp/version.rb +1 -1
- data/lib/easy_wamp/wamp.rb +15 -1
- data/lib/easy_wamp.rb +1 -0
- 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: 037a4697dda09147eaef568fe6236e99b2b82c71
|
4
|
+
data.tar.gz: e5793fb6eb70715f5c6cef82856b288080b6519a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b70d902afc4e90898eb0206fa144b5f66071e23dcd0981d708da5761f1ebfc4719effe1a1eb49c25bb0c6de02dcab5d74e787e63356f0b9cdece9288c9c3d2af
|
7
|
+
data.tar.gz: 4744834785b36bf7140040ee4d5b595e5d155789ad83a2c95fb50568264bbbaeca72dce499bbaca6760f4924e4284cb238661a223535f45d8a951446891a442a
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# EasyWamp
|
2
2
|
|
3
|
-
|
3
|
+
A simple full implementation of the wamp websocket protocol (http://wamp.ws/)
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -22,6 +22,14 @@ I designed the syntax to be close to DRB. The following will start the wamp ser
|
|
22
22
|
|
23
23
|
EasyWamp::WampServer.start_service("localhost", 9090, TestApi.new)
|
24
24
|
|
25
|
+
This will run the server in a thread, then return. The thread can be accessed with:
|
26
|
+
|
27
|
+
EasyWamp::WampServer.thread
|
28
|
+
|
29
|
+
So to pause execution and run the server just do:
|
30
|
+
|
31
|
+
EasyWamp::WampServer.thread.join
|
32
|
+
|
25
33
|
Where all WAMP remote procedure calls will be sent to the TestApi class. To publish an event on the server simply call:
|
26
34
|
|
27
35
|
EasyWamp::WampServer.publish_event("localhost/test/uri, "event_name", [exclusion_list], [inclusion_list])
|
data/lib/easy_wamp/version.rb
CHANGED
data/lib/easy_wamp/wamp.rb
CHANGED
@@ -16,11 +16,20 @@ module EasyWamp
|
|
16
16
|
@@events = {}
|
17
17
|
@@clients = {}
|
18
18
|
@@thread = nil
|
19
|
+
@@call_back = {}
|
19
20
|
|
20
21
|
def self.thread()
|
21
22
|
return @@thread
|
22
23
|
end
|
23
24
|
|
25
|
+
def self.register_callback(callback, &block)
|
26
|
+
@@call_back[callback] = block
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.call_callback(action, *args)
|
30
|
+
@@call_back[action].call(*args) if @@call_back[action]
|
31
|
+
end
|
32
|
+
|
24
33
|
def self.expand(curi)
|
25
34
|
@@prefix[curi.split(':')[0]] || curi
|
26
35
|
end
|
@@ -34,6 +43,7 @@ module EasyWamp
|
|
34
43
|
uri = expand(uri)
|
35
44
|
@@events[uri] ||= Set.new
|
36
45
|
@@events[uri].add(client)
|
46
|
+
call_callback(:on_subscribe, uri)
|
37
47
|
end
|
38
48
|
|
39
49
|
def self.unsubscribe(uri, client)
|
@@ -68,7 +78,9 @@ module EasyWamp
|
|
68
78
|
|
69
79
|
def self.each_registered(uri, bad, good)
|
70
80
|
@@events[uri].each do |e|
|
71
|
-
yield(get_client_ws(e)) if
|
81
|
+
yield(get_client_ws(e)) if get_client_ws(e) &&
|
82
|
+
!bad.include?(e) &&
|
83
|
+
(good == nil || good.empty? || good.include?(e))
|
72
84
|
end if(@@events[uri])
|
73
85
|
end
|
74
86
|
|
@@ -110,10 +122,12 @@ module EasyWamp
|
|
110
122
|
id = session_id()
|
111
123
|
register_new_client(ws, id)
|
112
124
|
send_welcome(ws, id)
|
125
|
+
call_callback(:on_open)
|
113
126
|
end
|
114
127
|
|
115
128
|
def self.handle_close(ws)
|
116
129
|
remove_client(ws)
|
130
|
+
call_callback(:on_close)
|
117
131
|
end
|
118
132
|
|
119
133
|
def self.handle_msg(ws, msg)
|
data/lib/easy_wamp.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_wamp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Curtis Bissonnette
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|