easy_wamp 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 319bba03e93e5f511544960b5e898018354f7a93
4
- data.tar.gz: 41341b9ed62dff61a39df9997c65b4ab34812a40
3
+ metadata.gz: 037a4697dda09147eaef568fe6236e99b2b82c71
4
+ data.tar.gz: e5793fb6eb70715f5c6cef82856b288080b6519a
5
5
  SHA512:
6
- metadata.gz: 3c7b2c2488b47e31ef86965b5c7a7838fed621a9c649ca34eb3f40a57b2707b26d671effdc6e4d86a09248a38fb0ca0c59075dfee17a3346ddc9d4d6b92b1e11
7
- data.tar.gz: c750f17df7b685fafd88a1364b3535826eec05a565836f0fb5a575642d7d240709089534f5a1e004fd3d079ee19caf258fc6c354e29076a4144cd46bf60adb74
6
+ metadata.gz: b70d902afc4e90898eb0206fa144b5f66071e23dcd0981d708da5761f1ebfc4719effe1a1eb49c25bb0c6de02dcab5d74e787e63356f0b9cdece9288c9c3d2af
7
+ data.tar.gz: 4744834785b36bf7140040ee4d5b595e5d155789ad83a2c95fb50568264bbbaeca72dce499bbaca6760f4924e4284cb238661a223535f45d8a951446891a442a
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # EasyWamp
2
2
 
3
- TODO: Write a gem description
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])
@@ -1,3 +1,3 @@
1
1
  module EasyWamp
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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 !bad.include?(e) && (good == nil || good.empty? || good.include?(e))
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
@@ -5,6 +5,7 @@ require 'json'
5
5
  require 'securerandom'
6
6
  require 'set'
7
7
  require 'thread'
8
+ require 'pry'
8
9
 
9
10
  require 'easy_wamp/version'
10
11
  require 'easy_wamp/wamp'
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.1
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: 2013-05-08 00:00:00.000000000 Z
11
+ date: 2014-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler