Class: Glottis::Handlers::RemoteOutputHandler

Inherits:
Thread
  • Object
show all
Defined in:
lib/glottis/handlers/remote_output_handler.rb

Overview

This class manages a TCP connection with a valyx server.

Constant Summary collapse

POLL_INTERVAL =
0.1
PROTOCOL =
'http'.freeze
REMOTE_PATHS =
{
  get_session: '/api/session',
  post_message: '/api/message'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(outgoing, host, port) ⇒ RemoteOutputHandler

Returns a new instance of RemoteOutputHandler.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/glottis/handlers/remote_output_handler.rb', line 18

def initialize(outgoing, host, port)
  @outgoing = outgoing
  @host = host
  @port = port

  setup_http

  super do
    @http.start
    request_session

    loop do
      send_queued
    end
  end
end

Instance Method Details

#cleanupObject



35
36
37
# File 'lib/glottis/handlers/remote_output_handler.rb', line 35

def cleanup
  @http.finish if @http.started?
end