apiotics 0.1.100 → 0.1.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62d44cf0a6a144746da74eef89c513853b76236f
4
- data.tar.gz: 2fa86199cfe4fe7392cfc347e007d376846707db
3
+ metadata.gz: 58892b459a343aeede24a416eca1b11e663913ca
4
+ data.tar.gz: eab39b6fdd5d030ce9b8fb84d791ea54f592701d
5
5
  SHA512:
6
- metadata.gz: 64faba1a078d9677239a0701c95eab30944de1aa7d1fc28981887c58ca431a4bd9ddee19d829fdbc65da56b6c5f29e9bf2afc4d7c13e63e35b902657bb71d4da
7
- data.tar.gz: 33b4685c362dc35e1fd1ee921ce0871dd95e1bf4be721286c201e861f5c704406e28708e33554c54d70c2822101ccccb5b3209bef0ca665bff1081df42965484
6
+ metadata.gz: daf1d03fcd2f26e3c5f7f83c8b64b9ad1e346bb815147139191afa01f2669cd5095510035f04324e04f927c4982ed38a890b98a4245946bde128157a5e332545
7
+ data.tar.gz: a679ddece5bc3f8dae4d924098cb1aca6235677ad61c281197b3160a443d047ad6e3b9a6b54cd9d390fc52631ff6ee0500334ce3d5635f44b9fc6924a8676b42
@@ -91,77 +91,66 @@ module Apiotics
91
91
  end
92
92
 
93
93
  def listen_remote
94
- begin
95
- Thread.new do
96
- loop do
97
- msg = @server.gets
98
- puts msg
99
- msg_hash = Apiotics::Parse.message(msg)
100
- unless msg_hash["driver"] == "Core::Heartbeat"
101
- r = Apiotics::Insert.new(msg_hash)
102
- puts "Message received": msg_hash
103
- if r.valid == true
104
- if r.action == "set-request-ack" || r.action == "set-complete" || r.action == "get-ack"
105
- r.save
106
- unless Apiotics.configuration.local_logging == false
107
- r.save_log
108
- end
94
+ Thread.abort_on_exception = true
95
+ Thread.new do
96
+ loop do
97
+ msg = @server.gets
98
+ puts msg
99
+ msg_hash = Apiotics::Parse.message(msg)
100
+ unless msg_hash["driver"] == "Core::Heartbeat"
101
+ r = Apiotics::Insert.new(msg_hash)
102
+ puts "Message received": msg_hash
103
+ if r.valid == true
104
+ if r.action == "set-request-ack" || r.action == "set-complete" || r.action == "get-ack"
105
+ r.save
106
+ unless Apiotics.configuration.local_logging == false
107
+ r.save_log
109
108
  end
110
109
  end
111
- else
112
- monitor_heartbeat(msg_hash)
113
110
  end
111
+ else
112
+ monitor_heartbeat(msg_hash)
114
113
  end
115
- ActiveRecord::Base.connection.close
116
114
  end
117
- rescue => e
118
- puts e
119
- listen_remote
115
+ ActiveRecord::Base.connection.close
120
116
  end
121
-
122
117
  end
123
118
 
124
119
  def listen_local
125
- begin
126
- if Apiotics.configuration.redis_comms_connection == false
127
- server = TCPServer.open(@localport)
128
- if Apiotics.configuration.handshake == true
129
- self.send('{"action":"connect"}')
130
- end
131
- loop do
132
- Thread.fork(server.accept) do |client|
133
- s = client.gets
134
- if @error_msg != nil
135
- string = '{"error":"' + error_msg + '"}'
136
- client.puts(string)
137
- end
138
- #puts s
139
- self.send(s)
140
- end
141
- end
142
- else
143
- if Apiotics.configuration.handshake == true
144
- self.send('{"action":"connect"}')
145
- end
146
- redis = ::Redis.new
147
- redis.subscribe(Apiotics.configuration.public_key) do |on|
148
- on.message do |channel, msg|
149
- if @error_msg != nil
150
- string = '{"error":"' + error_msg + '"}'
151
- client.puts(string)
152
- end
153
- #puts msg
154
- self.send(msg)
155
- end
120
+ if Apiotics.configuration.redis_comms_connection == false
121
+ server = TCPServer.open(@localport)
122
+ loop do
123
+ Thread.abort_on_exception = true
124
+ Thread.fork(server.accept) do |client|
125
+ s = client.gets
126
+ if @error_msg != nil
127
+ string = '{"error":"' + error_msg + '"}'
128
+ client.puts(string)
129
+ end
130
+ #puts s
131
+ self.send(s)
132
+ end
133
+ end
134
+ else
135
+ redis = ::Redis.new
136
+ redis.subscribe(Apiotics.configuration.public_key) do |on|
137
+ on.message do |channel, msg|
138
+ if @error_msg != nil
139
+ string = '{"error":"' + error_msg + '"}'
140
+ client.puts(string)
141
+ end
142
+ #puts msg
143
+ self.send(msg)
156
144
  end
157
145
  end
158
- rescue => e
159
- puts e
160
- listen_local
161
146
  end
162
147
  end
163
148
 
164
149
  def send_heartbeat(heartbeat)
150
+ if Apiotics.configuration.handshake == true
151
+ self.send('{"action":"connect"}')
152
+ end
153
+ Thread.abort_on_exception = true
165
154
  Thread.new do
166
155
  loop do
167
156
  heartbeat["interface"] = DateTime.now.to_i.to_s
@@ -1,3 +1,3 @@
1
1
  module Apiotics
2
- VERSION = '0.1.100'
2
+ VERSION = '0.1.101'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiotics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.100
4
+ version: 0.1.101
5
5
  platform: ruby
6
6
  authors:
7
7
  - MicroArx Corporation