websocket-eventmachine-base 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/websocket/eventmachine/base.rb +16 -6
- data/lib/websocket/eventmachine/base/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: ab8f99614a55d645b702a55b57adf360d77a7f2d
|
4
|
+
data.tar.gz: c1e0876073fb7ddc122d3e35264989600dc18396
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 789fd5bd8667a5664932b564f501a19ea5f99ee7b3f2f6af5c906d2d8b8836a7a4b68bd26487620322cb6727a4c133bdd8551e31aec8c8348de13395fce99a5b
|
7
|
+
data.tar.gz: 6f95f5a175c97bd7ed6c63d4b27400a1bc16fd8049d1c10d2fa67ca163287e5fe5cbe60edd2a6eb0234ed020bd31b93c871c30d7726cdd9932cba1be3c6ab2ea
|
data/CHANGELOG.md
CHANGED
@@ -25,7 +25,9 @@ module WebSocket
|
|
25
25
|
def onopen(&blk); @onopen = blk; end
|
26
26
|
|
27
27
|
# Called when connection is closed.
|
28
|
-
#
|
28
|
+
# Two parameters are passed to block:
|
29
|
+
# code - status code
|
30
|
+
# reason - optional reason for closure
|
29
31
|
def onclose(&blk); @onclose = blk; end
|
30
32
|
|
31
33
|
# Called when error occurs.
|
@@ -120,7 +122,7 @@ module WebSocket
|
|
120
122
|
unless @state == :closed
|
121
123
|
@state = :closed
|
122
124
|
close
|
123
|
-
trigger_onclose('')
|
125
|
+
trigger_onclose(1002, '')
|
124
126
|
end
|
125
127
|
end
|
126
128
|
|
@@ -137,13 +139,20 @@ module WebSocket
|
|
137
139
|
end
|
138
140
|
end
|
139
141
|
|
140
|
-
['onerror', 'onping', 'onpong'
|
142
|
+
['onerror', 'onping', 'onpong'].each do |m|
|
141
143
|
define_method "trigger_#{m}" do |data|
|
142
144
|
callback = instance_variable_get("@#{m}")
|
143
145
|
callback.call(data) if callback
|
144
146
|
end
|
145
147
|
end
|
146
148
|
|
149
|
+
['onclose'].each do |m|
|
150
|
+
define_method "trigger_#{m}" do |code, reason|
|
151
|
+
callback = instance_variable_get("@#{m}")
|
152
|
+
callback.call(code, reason) if callback
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
147
156
|
def trigger_onmessage(data, type)
|
148
157
|
@onmessage.call(data, type) if @onmessage
|
149
158
|
end
|
@@ -158,7 +167,7 @@ module WebSocket
|
|
158
167
|
trigger_onopen
|
159
168
|
handle_open(@handshake.leftovers) if @handshake.leftovers
|
160
169
|
else
|
161
|
-
trigger_onerror(@handshake.error)
|
170
|
+
trigger_onerror(@handshake.error.to_s)
|
162
171
|
close
|
163
172
|
end
|
164
173
|
end
|
@@ -171,7 +180,7 @@ module WebSocket
|
|
171
180
|
when :close
|
172
181
|
@state = :closing
|
173
182
|
close
|
174
|
-
trigger_onclose(frame.
|
183
|
+
trigger_onclose(frame.code, frame.data)
|
175
184
|
when :ping
|
176
185
|
pong(frame.to_s)
|
177
186
|
trigger_onping(frame.to_s)
|
@@ -194,6 +203,7 @@ module WebSocket
|
|
194
203
|
when :invalid_payload_encoding then 1007
|
195
204
|
else 1002
|
196
205
|
end
|
206
|
+
trigger_onerror(error.to_s)
|
197
207
|
close(error_code)
|
198
208
|
unbind
|
199
209
|
end
|
@@ -202,7 +212,7 @@ module WebSocket
|
|
202
212
|
unless @state == :closed
|
203
213
|
@state = :closed
|
204
214
|
close
|
205
|
-
trigger_onclose('')
|
215
|
+
trigger_onclose(1000, '')
|
206
216
|
end
|
207
217
|
end
|
208
218
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: websocket-eventmachine-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Potocki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket
|