wamp_client 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 461e1109df53efb8a73f4baa59154764499dc5b4
4
- data.tar.gz: 20bfbab92bcfa98139f4eaa21b00da249cbb0e3b
3
+ metadata.gz: 22086142dd8573b78491561c8f332d8e536250cf
4
+ data.tar.gz: f9d9182d4b29904e87d4b1aaf9626de3bb80eea5
5
5
  SHA512:
6
- metadata.gz: 92d7ade25879d7928d27aa83380d5f5196962fa241c325f556f4ae2da0fede72aa8198ef46a60f13d643c4121c4cc83d5bc7bc51fc5b3ee5ad8f8a79c5583335
7
- data.tar.gz: 8da8ebf72fabfe7edf6a4700233d7ee076b7d7d4e89295c4c42748059c30ef423c15c70c94802a815d2f7b50d2741aa6b8059bd5efb88dc4c382318f67182a3c
6
+ metadata.gz: 02ef5205e5f30a9fed3b8307eb52eacfe0f37b9829995d9132efdddeb4154ed13fc26e2e15153383257fa0dd33c4b1145db661627e96f45ecbed273d5dc6f329
7
+ data.tar.gz: 8b634eb7e49a67b4305b9e986994aad836dbb0145f1b0eebe2c1d169beb66747e10cec77db2c8a10c9a8816480cd225ee924c027b2c2eaf0d743e217921fbe89
data/README.md CHANGED
@@ -10,6 +10,8 @@ Please use [wamp_rails](https://github.com/ericchapman/ruby_wamp_rails) to integ
10
10
 
11
11
  ## Revision History
12
12
 
13
+ - v0.1.1:
14
+ - Added 'add_tick_loop' method to the transport to abstract the event machine
13
15
  - v0.1.0:
14
16
  - BREAKING CHANGE - Changed all of the namespaces to be "Wamp::Client"
15
17
  - v0.0.9:
@@ -147,6 +149,26 @@ connection.on(:challenge) do |authmethod, extra|
147
149
  end
148
150
  ```
149
151
 
152
+ #### Event Tick
153
+ You can run a task on every event machine tick by using the transport class
154
+ method 'add_tick_loop'
155
+
156
+ ```ruby
157
+ require 'wamp/client'
158
+
159
+ options = {
160
+ uri: 'ws://127.0.0.1:8080/ws',
161
+ realm: 'realm1',
162
+ }
163
+
164
+ connection = Wamp::Client::Connection.new(options)
165
+
166
+ connection.transport_class.add_tick_loop do
167
+ # Do something periodic
168
+ end
169
+
170
+ ```
171
+
150
172
  #### Overriding Transport
151
173
  By default, the library will use the "websocket-eventmachine-client" Gem as the websocket transport.
152
174
  However the library also supports overriding this.
@@ -146,6 +146,10 @@ module Wamp
146
146
  # Implement in subclass
147
147
  end
148
148
 
149
+ # Method to add a tick loop to the event machine
150
+ def self.add_tick_loop(&block)
151
+ # Implement in subclass
152
+ end
149
153
  end
150
154
  end
151
155
  end
@@ -50,6 +50,10 @@ module Wamp
50
50
  }
51
51
  end
52
52
 
53
+ def self.add_tick_loop(&block)
54
+ EM.tick_loop(&block)
55
+ end
56
+
53
57
  end
54
58
  end
55
59
  end
@@ -27,6 +27,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
27
 
28
28
  module Wamp
29
29
  module Client
30
- VERSION = '0.1.0'
30
+ VERSION = '0.1.1'
31
31
  end
32
32
  end
@@ -17,6 +17,18 @@ describe Wamp::Client::Transport do
17
17
  expect(value).to eq(10)
18
18
  end
19
19
 
20
+ it '#add_tick_loop' do
21
+ value = 0
22
+ described_class.start_event_machine do
23
+ described_class.add_tick_loop do
24
+ value += 1
25
+ described_class.stop_event_machine if value == 10
26
+ end
27
+ end
28
+
29
+ expect(value).to eq(10)
30
+ end
31
+
20
32
  context '#add_timer' do
21
33
  include RSpec::EM::FakeClock
22
34
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wamp_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Chapman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-21 00:00:00.000000000 Z
11
+ date: 2018-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler