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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a75ada130e34ec2730b2d8571091ce6d97370851
4
- data.tar.gz: e6e1c3ec4d8b19f62a7b1124d93a103c76f84126
3
+ metadata.gz: ab8f99614a55d645b702a55b57adf360d77a7f2d
4
+ data.tar.gz: c1e0876073fb7ddc122d3e35264989600dc18396
5
5
  SHA512:
6
- metadata.gz: 7e09acc073f641a7d4ae024fa40c86aaf7f3e72d92a7fef213ae31ffe074e9d7e98b665b3caa04153cd5b9f8f201b59eec81d3f280a5ca173cc337e6855a4906
7
- data.tar.gz: fab4a0281c5369c0555bfa165f0d20707d1b19fe45d340b23e923c62376743e52b95c76997e0d53477e5b9ee6bfc0b650c6310cad5be566928f2159f2c1e9b9b
6
+ metadata.gz: 789fd5bd8667a5664932b564f501a19ea5f99ee7b3f2f6af5c906d2d8b8836a7a4b68bd26487620322cb6727a4c133bdd8551e31aec8c8348de13395fce99a5b
7
+ data.tar.gz: 6f95f5a175c97bd7ed6c63d4b27400a1bc16fd8049d1c10d2fa67ca163287e5fe5cbe60edd2a6eb0234ed020bd31b93c871c30d7726cdd9932cba1be3c6ab2ea
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ - return status code and message instead of just message in on_close callback (@Sumo-MBryant)
6
+ - you can now pass custom headers for client handshake (@Sumo-MBryant)
7
+
3
8
  ## 1.0.3
4
9
 
5
10
  - return proper close codes
@@ -25,7 +25,9 @@ module WebSocket
25
25
  def onopen(&blk); @onopen = blk; end
26
26
 
27
27
  # Called when connection is closed.
28
- # No parameters are passed to block
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', 'onclose'].each do |m|
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.to_s)
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
 
@@ -1,7 +1,7 @@
1
1
  module WebSocket
2
2
  module EventMachine
3
3
  class Base
4
- VERSION = '1.0.3'
4
+ VERSION = '1.1.0'
5
5
  end
6
6
  end
7
7
  end
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.3
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-05-03 00:00:00.000000000 Z
11
+ date: 2014-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket