faye-websocket 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of faye-websocket might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/faye/websocket.rb +1 -1
- data/lib/faye/websocket/api.rb +57 -37
- data/lib/faye/websocket/client.rb +6 -8
- 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: e55b90e0392792e40296464c5bfb0419042dac2a
|
4
|
+
data.tar.gz: 6d7a46c812d1c98cf23b5fe4f5b7c82149ae2144
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 807a1837ccc7d7817f611c21aeeb05d7d8e64795e10b83aaf6bb93145044e956626b27feeef228dca7ea21b7930c544caf11f6d37f95d5b6c463d3d300b6e2b4
|
7
|
+
data.tar.gz: eefb00619befa06948f8d2752b6c670d16ed2ae1da71809780b7c3b0400b799118fd241758afd9c6565b8916a8b17af3f222afd3480e2c185776b7de1779beca
|
data/CHANGELOG.md
CHANGED
data/lib/faye/websocket.rb
CHANGED
data/lib/faye/websocket/api.rb
CHANGED
@@ -36,12 +36,10 @@ module Faye
|
|
36
36
|
|
37
37
|
@driver.on(:open) { |e| open }
|
38
38
|
@driver.on(:message) { |e| receive_message(e.data) }
|
39
|
-
@driver.on(:close) { |e|
|
39
|
+
@driver.on(:close) { |e| begin_close(e.reason, e.code) }
|
40
40
|
|
41
41
|
@driver.on(:error) do |error|
|
42
|
-
|
43
|
-
event.init_event('error', false, false)
|
44
|
-
dispatch_event(event)
|
42
|
+
emit_error(error.message)
|
45
43
|
end
|
46
44
|
|
47
45
|
if @ping
|
@@ -52,6 +50,34 @@ module Faye
|
|
52
50
|
end
|
53
51
|
end
|
54
52
|
|
53
|
+
def write(data)
|
54
|
+
@stream.write(data)
|
55
|
+
end
|
56
|
+
|
57
|
+
def send(message)
|
58
|
+
return false if @ready_state > OPEN
|
59
|
+
case message
|
60
|
+
when Numeric then @driver.text(message.to_s)
|
61
|
+
when String then @driver.text(message)
|
62
|
+
when Array then @driver.binary(message)
|
63
|
+
else false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def ping(message = '', &callback)
|
68
|
+
return false if @ready_state > OPEN
|
69
|
+
@driver.ping(message, &callback)
|
70
|
+
end
|
71
|
+
|
72
|
+
def close
|
73
|
+
@ready_state = CLOSING unless @ready_state == CLOSED
|
74
|
+
@driver.close
|
75
|
+
end
|
76
|
+
|
77
|
+
def protocol
|
78
|
+
@driver.protocol || ''
|
79
|
+
end
|
80
|
+
|
55
81
|
private
|
56
82
|
|
57
83
|
def open
|
@@ -69,49 +95,43 @@ module Faye
|
|
69
95
|
dispatch_event(event)
|
70
96
|
end
|
71
97
|
|
72
|
-
def
|
73
|
-
return if @ready_state
|
74
|
-
@ready_state = CLOSED
|
75
|
-
EventMachine.cancel_timer(@ping_timer) if @ping_timer
|
76
|
-
@stream.close_connection_after_writing if @stream
|
77
|
-
event = Event.create('close', :code => code || 1000, :reason => reason || '')
|
78
|
-
event.init_event('close', false, false)
|
79
|
-
dispatch_event(event)
|
80
|
-
end
|
98
|
+
def emit_error(message)
|
99
|
+
return if @ready_state >= CLOSING
|
81
100
|
|
82
|
-
|
83
|
-
|
84
|
-
|
101
|
+
event = Event.create('error', :message => message)
|
102
|
+
event.init_event('error', false, false)
|
103
|
+
dispatch_event(event)
|
85
104
|
end
|
86
105
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
@stream.write(data)
|
91
|
-
end
|
106
|
+
def begin_close(reason, code)
|
107
|
+
return if @ready_state == CLOSED
|
108
|
+
@ready_state = CLOSING
|
92
109
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
when String then @driver.text(message)
|
98
|
-
when Array then @driver.binary(message)
|
99
|
-
else false
|
110
|
+
if @stream
|
111
|
+
@stream.close_connection_after_writing
|
112
|
+
else
|
113
|
+
finalize_close
|
100
114
|
end
|
115
|
+
@close_params = [reason, code]
|
101
116
|
end
|
102
117
|
|
103
|
-
def
|
104
|
-
return
|
105
|
-
@
|
106
|
-
end
|
118
|
+
def finalize_close
|
119
|
+
return if @ready_state == CLOSED
|
120
|
+
@ready_state = CLOSED
|
107
121
|
|
108
|
-
|
109
|
-
|
110
|
-
@
|
122
|
+
EventMachine.cancel_timer(@ping_timer) if @ping_timer
|
123
|
+
|
124
|
+
reason = @close_params ? @close_params[0] : ''
|
125
|
+
code = @close_params ? @close_params[1] : 1006
|
126
|
+
|
127
|
+
event = Event.create('close', :code => code, :reason => reason)
|
128
|
+
event.init_event('close', false, false)
|
129
|
+
dispatch_event(event)
|
111
130
|
end
|
112
131
|
|
113
|
-
def
|
114
|
-
@
|
132
|
+
def parse(data)
|
133
|
+
worker = @proxy || @driver
|
134
|
+
worker.parse(data)
|
115
135
|
end
|
116
136
|
end
|
117
137
|
|
@@ -50,19 +50,17 @@ module Faye
|
|
50
50
|
end
|
51
51
|
|
52
52
|
EventMachine.connect(endpoint.host, port, Connection) do |conn|
|
53
|
-
@stream = conn
|
54
53
|
conn.parent = self
|
55
54
|
end
|
56
55
|
rescue => error
|
57
|
-
|
58
|
-
|
59
|
-
dispatch_event(event)
|
60
|
-
finalize('', 1006)
|
56
|
+
emit_error("Network error: #{url}: #{error.message}")
|
57
|
+
finalize_close
|
61
58
|
end
|
62
59
|
|
63
60
|
private
|
64
61
|
|
65
|
-
def on_connect()
|
62
|
+
def on_connect(stream)
|
63
|
+
@stream = stream
|
66
64
|
@stream.start_tls(@socket_tls) if @secure
|
67
65
|
worker = @proxy || @driver
|
68
66
|
worker.start
|
@@ -72,7 +70,7 @@ module Faye
|
|
72
70
|
attr_accessor :parent
|
73
71
|
|
74
72
|
def connection_completed
|
75
|
-
parent.__send__(:on_connect)
|
73
|
+
parent.__send__(:on_connect, self)
|
76
74
|
end
|
77
75
|
|
78
76
|
def receive_data(data)
|
@@ -80,7 +78,7 @@ module Faye
|
|
80
78
|
end
|
81
79
|
|
82
80
|
def unbind
|
83
|
-
parent.__send__(:
|
81
|
+
parent.__send__(:finalize_close)
|
84
82
|
end
|
85
83
|
|
86
84
|
def write(data)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faye-websocket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Coglan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|