Class: MappingServer

Inherits:
Object
  • Object
show all
Defined in:
lib/MINT-core/manager/mapping_server.rb

Defined Under Namespace

Classes: StatefulProtocol

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hsh = {:host=>"0.0.0.0",:port=>8000}) ⇒ MappingServer

Returns a new instance of MappingServer.



75
76
77
78
79
# File 'lib/MINT-core/manager/mapping_server.rb', line 75

def initialize(hsh = {:host=>"0.0.0.0",:port=>8000})
  @host = hsh[:host]
  @port = hsh[:port]
  @connections =[]
end

Instance Attribute Details

#connectionsObject

Returns the value of attribute connections.



8
9
10
# File 'lib/MINT-core/manager/mapping_server.rb', line 8

def connections
  @connections
end

#managerObject

Returns the value of attribute manager.



9
10
11
# File 'lib/MINT-core/manager/mapping_server.rb', line 9

def manager
  @manager
end

Instance Method Details

#start(manager = nil) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/MINT-core/manager/mapping_server.rb', line 81

def start(manager = nil)

  if (manager)
    @manager = manager
  else
    @manager = MappingManager.new
  end
  EventMachine::start_server @host, @port, StatefulProtocol do |conn|
    @connections << conn
    conn.send_data("READY\r\n")
    conn.manager=@manager
    puts "connection..."
  end
  puts "Started server on #{@host}:#{@port}"
end