Class: EMRPC::ReconnectingClient

Inherits:
Object
  • Object
show all
Defined in:
lib/emrpc/reconnecting_client.rb

Overview

Reconnects when needed.

Defined Under Namespace

Modules: ReconnectingCallbacks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ReconnectingClient

Returns a new instance of ReconnectingClient.



5
6
7
8
9
10
11
12
# File 'lib/emrpc/reconnecting_client.rb', line 5

def initialize(options)
  @host     = options[:host]
  @port     = options[:port]
  @protocol = options[:protocol]
  @timeout  = options[:timeout]
  
  @connection = nil # diconnected at the start
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



4
5
6
# File 'lib/emrpc/reconnecting_client.rb', line 4

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



4
5
6
# File 'lib/emrpc/reconnecting_client.rb', line 4

def port
  @port
end

#protocolObject (readonly)

Returns the value of attribute protocol.



4
5
6
# File 'lib/emrpc/reconnecting_client.rb', line 4

def protocol
  @protocol
end

Instance Method Details

#close_connection(after_writing = false) ⇒ Object



23
24
25
# File 'lib/emrpc/reconnecting_client.rb', line 23

def close_connection(after_writing = false)
  
end

#connectionObject



14
15
16
17
# File 'lib/emrpc/reconnecting_client.rb', line 14

def connection
  return @connection if @connection
  
end

#send_data(data) ⇒ Object



19
20
21
# File 'lib/emrpc/reconnecting_client.rb', line 19

def send_data(data)
  connection.send_data
end