wamp_client 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/wamp/client.rb +37 -0
- data/lib/wamp/client/connection.rb +14 -6
- data/lib/wamp/client/session.rb +12 -7
- data/lib/wamp/client/version.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- metadata +25 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5735e4d3344f243325a9226289448ea18b3cf27d
|
4
|
+
data.tar.gz: cbd5aa1d9ae5d059d8ebbc655a6fd3b80ff17c32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15aa5f6f522da9cc50c336078d2d93d0190bbe07449177499f77df36464c2a14d80a359e6190ebaa6cb762bceecd2080677d0c51501d44f5d952ceb94e297b11
|
7
|
+
data.tar.gz: 135d51166dfb40468ebb8eb603a5707cb9cb02d1b5685378499849e8b2d8cb167d87031956e1b367cf679ba0bde03e18f4b6c420efac9bf2178586fe0fdea6ac
|
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.2:
|
14
|
+
- Updated logging to use the standard Ruby logger
|
13
15
|
- v0.1.1:
|
14
16
|
- Added 'add_tick_loop' method to the transport to abstract the event machine
|
15
17
|
- v0.1.0:
|
data/lib/wamp/client.rb
CHANGED
@@ -32,3 +32,40 @@ require 'wamp/client/connection'
|
|
32
32
|
require 'wamp/client/session'
|
33
33
|
require 'wamp/client/auth'
|
34
34
|
require 'wamp/client/defer'
|
35
|
+
require 'logger'
|
36
|
+
|
37
|
+
module Wamp
|
38
|
+
module Client
|
39
|
+
|
40
|
+
# Returns the logger object
|
41
|
+
#
|
42
|
+
def self.logger
|
43
|
+
unless defined?(@logger)
|
44
|
+
@logger = Logger.new(STDOUT)
|
45
|
+
@logger.level = Logger::INFO
|
46
|
+
end
|
47
|
+
@logger
|
48
|
+
end
|
49
|
+
|
50
|
+
# Sets the log level
|
51
|
+
#
|
52
|
+
# @param log_level [Symbol] - the desired log level
|
53
|
+
def self.log_level=(log_level)
|
54
|
+
level =
|
55
|
+
case log_level
|
56
|
+
when :error
|
57
|
+
Logger::ERROR
|
58
|
+
when :debug
|
59
|
+
Logger::DEBUG
|
60
|
+
when :fatal
|
61
|
+
Logger::FATAL
|
62
|
+
when :warn
|
63
|
+
Logger::WARN
|
64
|
+
else
|
65
|
+
Logger::INFO
|
66
|
+
end
|
67
|
+
self.logger.level = level
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -32,7 +32,7 @@ require 'wamp/client/transport/faye_web_socket'
|
|
32
32
|
module Wamp
|
33
33
|
module Client
|
34
34
|
class Connection
|
35
|
-
attr_accessor :options, :transport_class, :transport, :session
|
35
|
+
attr_accessor :options, :transport_class, :transport, :session
|
36
36
|
|
37
37
|
@reconnect = true
|
38
38
|
|
@@ -108,7 +108,6 @@ module Wamp
|
|
108
108
|
def initialize(options)
|
109
109
|
self.transport_class = options.delete(:transport) || Wamp::Client::Transport::WebSocketEventMachine
|
110
110
|
self.options = options || {}
|
111
|
-
self.verbose = options[:verbose] || false
|
112
111
|
end
|
113
112
|
|
114
113
|
# Opens the connection
|
@@ -183,7 +182,8 @@ module Wamp
|
|
183
182
|
|
184
183
|
# Setup transport callbacks
|
185
184
|
self.transport.on(:open) do
|
186
|
-
|
185
|
+
|
186
|
+
logger.info("#{self.class.name} TRANSPORT OPEN")
|
187
187
|
|
188
188
|
# Call the callback
|
189
189
|
@on_connect.call if @on_connect
|
@@ -194,7 +194,7 @@ module Wamp
|
|
194
194
|
end
|
195
195
|
|
196
196
|
self.transport.on(:close) do |reason|
|
197
|
-
|
197
|
+
logger.info("#{self.class.name} TRANSPORT CLOSED: #{reason}")
|
198
198
|
@open = false
|
199
199
|
|
200
200
|
unless @retrying
|
@@ -214,7 +214,7 @@ module Wamp
|
|
214
214
|
end
|
215
215
|
|
216
216
|
self.transport.on(:error) do |message|
|
217
|
-
|
217
|
+
logger.error("#{self.class.name} TRANSPORT ERROR: #{message}")
|
218
218
|
end
|
219
219
|
|
220
220
|
@open = true
|
@@ -236,7 +236,7 @@ module Wamp
|
|
236
236
|
|
237
237
|
self._create_transport
|
238
238
|
|
239
|
-
|
239
|
+
logger.info("#{self.class.name} RECONNECT in #{@retry_timer} seconds")
|
240
240
|
self.transport_class.add_timer(@retry_timer*1000) do
|
241
241
|
self._retry if @retrying
|
242
242
|
end
|
@@ -244,6 +244,14 @@ module Wamp
|
|
244
244
|
|
245
245
|
end
|
246
246
|
|
247
|
+
private
|
248
|
+
|
249
|
+
# Returns the logger
|
250
|
+
#
|
251
|
+
def logger
|
252
|
+
Wamp::Client.logger
|
253
|
+
end
|
254
|
+
|
247
255
|
end
|
248
256
|
end
|
249
257
|
end
|
data/lib/wamp/client/session.rb
CHANGED
@@ -181,7 +181,7 @@ module Wamp
|
|
181
181
|
end
|
182
182
|
end
|
183
183
|
|
184
|
-
attr_accessor :id, :realm, :transport, :
|
184
|
+
attr_accessor :id, :realm, :transport, :options
|
185
185
|
|
186
186
|
# Private attributes
|
187
187
|
attr_accessor :_goodbye_sent, :_requests, :_subscriptions, :_registrations, :_defers
|
@@ -197,7 +197,6 @@ module Wamp
|
|
197
197
|
self.id = nil
|
198
198
|
self.realm = nil
|
199
199
|
self.options = options || {}
|
200
|
-
self.verbose = self.options[:verbose]
|
201
200
|
|
202
201
|
# Outstanding Requests
|
203
202
|
self._requests = {
|
@@ -294,7 +293,7 @@ module Wamp
|
|
294
293
|
# Sends a message
|
295
294
|
# @param msg [Wamp::Client::Message::Base]
|
296
295
|
def _send_message(msg)
|
297
|
-
|
296
|
+
logger.debug("#{self.class.name} TX: #{msg.to_s}")
|
298
297
|
self.transport.send_message(msg.payload)
|
299
298
|
end
|
300
299
|
|
@@ -304,10 +303,8 @@ module Wamp
|
|
304
303
|
|
305
304
|
message = Wamp::Client::Message::Base.parse(msg)
|
306
305
|
|
307
|
-
|
308
|
-
|
309
|
-
puts 'RX(non-wamp): ' + msg.to_s unless message
|
310
|
-
end
|
306
|
+
logger.debug("#{self.class.name} RX: #{message.to_s}")
|
307
|
+
logger.debug("#{self.class.name} RX(non-samp): #{msg.to_s}")
|
311
308
|
|
312
309
|
# WAMP Session is not open
|
313
310
|
if self.id.nil?
|
@@ -996,6 +993,14 @@ module Wamp
|
|
996
993
|
|
997
994
|
#endregion
|
998
995
|
|
996
|
+
private
|
997
|
+
|
998
|
+
# Returns the logger
|
999
|
+
#
|
1000
|
+
def logger
|
1001
|
+
Wamp::Client.logger
|
1002
|
+
end
|
1003
|
+
|
999
1004
|
end
|
1000
1005
|
end
|
1001
1006
|
end
|
data/lib/wamp/client/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,139 +1,139 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wamp_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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
|
+
date: 2018-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.7'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.5.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.5.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec-eventmachine
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.2.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.2.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: codecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: faye-websocket
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 0.10.4
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.10.4
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: websocket-eventmachine-client
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 1.1.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 1.1.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: json
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
description: An implementation of The Web Application Messaging Protocol (WAMP)
|
@@ -143,8 +143,8 @@ executables: []
|
|
143
143
|
extensions: []
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
|
-
- .gitignore
|
147
|
-
- .ruby-version
|
146
|
+
- ".gitignore"
|
147
|
+
- ".ruby-version"
|
148
148
|
- Gemfile
|
149
149
|
- LICENSE.txt
|
150
150
|
- README.md
|
@@ -183,17 +183,17 @@ require_paths:
|
|
183
183
|
- lib
|
184
184
|
required_ruby_version: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
|
-
- -
|
186
|
+
- - ">="
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: '2.0'
|
189
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
190
|
requirements:
|
191
|
-
- -
|
191
|
+
- - ">="
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
195
|
rubyforge_project:
|
196
|
-
rubygems_version: 2.
|
196
|
+
rubygems_version: 2.5.1
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: Web Application Messaging Protocol Client
|