se-realtime 0.0.0.beta1 → 0.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +2 -2
- data/lib/se/realtime/version.rb +1 -1
- data/lib/se/realtime/websocket.rb +15 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8be232d89599d222902c7b5a6abe0373883d2c1c4de86bb845716da814f0008d
|
4
|
+
data.tar.gz: 810386b632a4015837af3cc003437c1eb2ab97ca1a39216f9b7e0278f867465d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83758de91c6098a3ebfee3b3dd0afd318706d6e058d8f7fb5fc85e8873b5470950d3fc3a4d17b7868b08b066b31546871e57eeed5a16cf0b11c41118b2071501
|
7
|
+
data.tar.gz: c2dee666b75a47a25401822cec95875f43dc5c23eaf55bd62cf1abe51620a1e078639c2e7d89ac84498303d605ee12a86a67bd55a5a0572e98c3d573fb44749c
|
data/Gemfile.lock
CHANGED
data/lib/se/realtime/version.rb
CHANGED
@@ -17,7 +17,8 @@ module SE
|
|
17
17
|
@driver = WebSocket::Driver.client(self)
|
18
18
|
@socket = TCPSocket.new(@uri.host, 80)
|
19
19
|
@handler = handler
|
20
|
-
@logger = Logger.new "realtime
|
20
|
+
@logger = Logger.new "realtime.log"
|
21
|
+
@restart = true
|
21
22
|
|
22
23
|
@driver.add_extension PermessageDeflate
|
23
24
|
@driver.set_header "Cookies", cookies if cookies
|
@@ -27,7 +28,7 @@ module SE
|
|
27
28
|
|
28
29
|
@driver.on :open, ->(_e) do
|
29
30
|
send "155-questions-active"
|
30
|
-
|
31
|
+
@logger.info "WebSocket is open!"
|
31
32
|
end
|
32
33
|
|
33
34
|
@driver.on :message do |e|
|
@@ -40,14 +41,21 @@ module SE
|
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
43
|
-
@driver.on :close, ->(_e)
|
44
|
+
@driver.on :close, ->(_e) do
|
45
|
+
@logger.info "Realtime WebSocket is closing."
|
46
|
+
if @restart
|
47
|
+
@logger.info "Attempting to reopen websocket..."
|
48
|
+
@driver.start
|
49
|
+
end
|
50
|
+
end
|
44
51
|
|
45
|
-
@driver.on :error, ->(e) {
|
52
|
+
@driver.on :error, ->(e) { @logger.error e }
|
46
53
|
|
47
54
|
@driver.start
|
48
55
|
|
49
56
|
@thread = Thread.new do
|
50
57
|
trap("SIGINT") do
|
58
|
+
@restart = false
|
51
59
|
close
|
52
60
|
Thread.exit
|
53
61
|
end
|
@@ -55,7 +63,7 @@ module SE
|
|
55
63
|
begin
|
56
64
|
@driver.parse(@socket.recv(1))
|
57
65
|
rescue IOError, SystemCallError => e
|
58
|
-
|
66
|
+
@logger.warn "Recieved #{e} closing TCP socket. You shouldn't be worried :)"
|
59
67
|
end
|
60
68
|
end
|
61
69
|
end
|
@@ -64,7 +72,7 @@ module SE
|
|
64
72
|
end
|
65
73
|
|
66
74
|
def send(message)
|
67
|
-
|
75
|
+
@logger.info "Lub dub" if message == "hb"
|
68
76
|
@logger.info("Wrote: #{message}")
|
69
77
|
@driver.text(message)
|
70
78
|
end
|
@@ -77,7 +85,7 @@ module SE
|
|
77
85
|
@driver.close
|
78
86
|
@socket.shutdown
|
79
87
|
rescue IOError, Errno::ENOTCONN => e
|
80
|
-
|
88
|
+
@logger.error "Recieved #{e.class} trying to close websocket. Ignoring..."
|
81
89
|
end
|
82
90
|
end
|
83
91
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: se-realtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.0.
|
4
|
+
version: 0.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thesecretmaster
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: 1.3.1
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
152
|
+
rubygems_version: 2.7.3
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: A SE realtime feed reader
|