websocket-eventmachine-base 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/lib/websocket/eventmachine/base/version.rb +1 -1
- data/lib/websocket/eventmachine/base.rb +24 -17
- metadata +1 -1
data/CHANGELOG.md
CHANGED
@@ -48,6 +48,7 @@ module WebSocket
|
|
48
48
|
# @return [Boolean] true if data was send, otherwise call on_error if needed
|
49
49
|
def send(data, args = {})
|
50
50
|
type = args[:type] || :text
|
51
|
+
return if @state == :closed || (@state == :closing && type != :close)
|
51
52
|
unless type == :plain
|
52
53
|
frame = outgoing_frame.new(:version => @handshake.version, :data => data, :type => type.to_s, :code => args[:code])
|
53
54
|
if !frame.supported?
|
@@ -156,29 +157,35 @@ module WebSocket
|
|
156
157
|
def handle_open(data)
|
157
158
|
@frame << data
|
158
159
|
while frame = @frame.next
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
160
|
+
if @state == :open
|
161
|
+
case frame.type
|
162
|
+
when :close
|
163
|
+
@state = :closing
|
164
|
+
close
|
165
|
+
trigger_onclose(frame.to_s)
|
166
|
+
when :ping
|
167
|
+
pong(frame.to_s)
|
168
|
+
trigger_onping(frame.to_s)
|
169
|
+
when :pong
|
170
|
+
trigger_onpong(frame.to_s)
|
171
|
+
when :text
|
172
|
+
trigger_onmessage(frame.to_s, :text)
|
173
|
+
when :binary
|
174
|
+
trigger_onmessage(frame.to_s, :binary)
|
175
|
+
end
|
176
|
+
else
|
177
|
+
break
|
173
178
|
end
|
174
179
|
end
|
175
180
|
unbind if @frame.error?
|
176
181
|
end
|
177
182
|
|
178
183
|
def handle_closing(data)
|
179
|
-
@state
|
180
|
-
|
181
|
-
|
184
|
+
unless @state == :closed
|
185
|
+
@state = :closed
|
186
|
+
close
|
187
|
+
trigger_onclose('')
|
188
|
+
end
|
182
189
|
end
|
183
190
|
|
184
191
|
def debug(description, data)
|