Class: EMRPC::LocalConnection

Inherits:
Object
  • Object
show all
Includes:
ConnectionMixin
Defined in:
lib/emrpc/evented_api/local_connection.rb

Defined Under Namespace

Classes: Channel

Constant Summary collapse

LOCALNODE_ADDRESS =
'emrpc://localnode/'.parsed_uri.freeze

Instance Attribute Summary collapse

Attributes included from ConnectionMixin

#connected_callback, #disconnected_callback, #local_pid, #remote_pid

Instance Method Summary collapse

Constructor Details

#initialize(local_pid, remote_pid, channel = nil) ⇒ LocalConnection

Returns a new instance of LocalConnection.



23
24
25
26
27
# File 'lib/emrpc/evented_api/local_connection.rb', line 23

def initialize(local_pid, remote_pid, channel = nil)
  @channel = channel || Channel.new(local_pid, remote_pid, self)
  @local_pid = local_pid
  @remote_pid = local_pid.connection_established(remote_pid, self)
end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



21
22
23
# File 'lib/emrpc/evented_api/local_connection.rb', line 21

def channel
  @channel
end

Instance Method Details

#addressObject



43
44
45
# File 'lib/emrpc/evented_api/local_connection.rb', line 43

def address
  LOCALNODE_ADDRESS
end

#close_connectionObject Also known as: close_connection_after_writing



37
38
39
# File 'lib/emrpc/evented_api/local_connection.rb', line 37

def close_connection
  @channel.unbind
end

#unbindObject



29
30
31
32
33
34
35
# File 'lib/emrpc/evented_api/local_connection.rb', line 29

def unbind
  lpid = @local_pid
  rpid = @remote_pid
  @local_pid = nil
  @remote_pid = nil
  lpid.connection_unbind(rpid, self)
end