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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 99186f6f66fdcc6578e58711019984ec0fd9911e
4
- data.tar.gz: 5f92c4c7cbcde8e943b79165eeec8722ad4eb415
2
+ SHA256:
3
+ metadata.gz: 8be232d89599d222902c7b5a6abe0373883d2c1c4de86bb845716da814f0008d
4
+ data.tar.gz: 810386b632a4015837af3cc003437c1eb2ab97ca1a39216f9b7e0278f867465d
5
5
  SHA512:
6
- metadata.gz: 0a7bc67b138ac70d88044fb55e42e37fba688e95de796f39d8ffb0e331540168ddad382bb531ae0a71490f396ef5283bb3a139ef403e5e981778f0dd4df91777
7
- data.tar.gz: 0610f196988de9099cb0f09849b101d78276e6e9a43d0886ee9ab4cea94617b45be2411a285e677bcc026cdd707cd57e557d4489ad047963e928a0f9a60887d6
6
+ metadata.gz: 83758de91c6098a3ebfee3b3dd0afd318706d6e058d8f7fb5fc85e8873b5470950d3fc3a4d17b7868b08b066b31546871e57eeed5a16cf0b11c41118b2071501
7
+ data.tar.gz: c2dee666b75a47a25401822cec95875f43dc5c23eaf55bd62cf1abe51620a1e078639c2e7d89ac84498303d605ee12a86a67bd55a5a0572e98c3d573fb44749c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- se-realtime (0.0.0.beta1)
4
+ se-realtime (0.0.0.beta2)
5
5
  mechanize (~> 2.7)
6
6
  nokogiri (~> 1.8)
7
7
  permessage_deflate (~> 0.1)
@@ -53,4 +53,4 @@ DEPENDENCIES
53
53
  se-realtime!
54
54
 
55
55
  BUNDLED WITH
56
- 1.16.0
56
+ 1.16.1
@@ -1,5 +1,5 @@
1
1
  module SE
2
2
  module Realtime
3
- VERSION = "0.0.0.beta1".freeze
3
+ VERSION = "0.0.0.beta2".freeze
4
4
  end
5
5
  end
@@ -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-#{DateTime.now.strftime('%Q')}.log"
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
- puts "WebSocket is open!"
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) { puts "WebSocket is closed!"}
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) { STDERR.puts 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
- puts "Recieved #{e} closing TCP socket. You shouldn't be worried :)"
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
- puts "Lub dub" if message == "hb"
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
- STDERR.puts "Recieved #{e.class} trying to close websocket. Ignoring..."
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.beta1
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-14 00:00:00.000000000 Z
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.6.11
152
+ rubygems_version: 2.7.3
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: A SE realtime feed reader