Class: CarbonMU::Connection

Inherits:
Object
  • Object
show all
Includes:
Celluloid::IO, Celluloid::Logger
Defined in:
lib/edge_router/connection.rb

Direct Known Subclasses

TelnetConnection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg = nil) ⇒ Connection

Returns a new instance of Connection.


11
12
13
14
# File 'lib/edge_router/connection.rb', line 11

def initialize(arg = nil)
  @id = SecureRandom.uuid
  after_initialize(arg)
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id


7
8
9
# File 'lib/edge_router/connection.rb', line 7

def id
  @id
end

#nameObject

Returns the value of attribute name


6
7
8
# File 'lib/edge_router/connection.rb', line 6

def name
  @name
end

Instance Method Details

#after_initialize(arg) ⇒ Object


16
17
18
# File 'lib/edge_router/connection.rb', line 16

def after_initialize(arg)
  nil # to be implemented by subclasses, if desired
end

#before_shutdownObject


34
35
36
# File 'lib/edge_router/connection.rb', line 34

def before_shutdown
  nil # to be implemented by subclasses, if desired
end

#handle_input(input) ⇒ Object


20
21
22
23
# File 'lib/edge_router/connection.rb', line 20

def handle_input(input)
  input.chomp!
  Actor[:edge_router].async.send_command_to_server(input, id)
end

#runObject

Raises:

  • (NotImplementedError)

25
26
27
# File 'lib/edge_router/connection.rb', line 25

def run
  raise NotImplementedError
end

#shutdownObject


29
30
31
32
# File 'lib/edge_router/connection.rb', line 29

def shutdown
  before_shutdown
  Actor[:edge_router].async.remove_connection(Actor.current)
end