Class: MudServer::Session
- Inherits:
-
Object
- Object
- MudServer::Session
- Defined in:
- lib/session.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#input_thread ⇒ Object
Returns the value of attribute input_thread.
-
#ip_addr ⇒ Object
Returns the value of attribute ip_addr.
Instance Method Summary collapse
- #bootstrap_settings(connection, controller) ⇒ Object
-
#initialize(connection, controller = MudServer::DefaultController) ⇒ Session
constructor
A new instance of Session.
- #start ⇒ Object
Constructor Details
#initialize(connection, controller = MudServer::DefaultController) ⇒ Session
Returns a new instance of Session.
5 6 7 8 |
# File 'lib/session.rb', line 5 def initialize(connection, controller = MudServer::DefaultController) bootstrap_settings(connection, controller) start end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
3 4 5 |
# File 'lib/session.rb', line 3 def connection @connection end |
#controller ⇒ Object
Returns the value of attribute controller.
3 4 5 |
# File 'lib/session.rb', line 3 def controller @controller end |
#input_thread ⇒ Object
Returns the value of attribute input_thread.
3 4 5 |
# File 'lib/session.rb', line 3 def input_thread @input_thread end |
#ip_addr ⇒ Object
Returns the value of attribute ip_addr.
3 4 5 |
# File 'lib/session.rb', line 3 def ip_addr @ip_addr end |
Instance Method Details
#bootstrap_settings(connection, controller) ⇒ Object
10 11 12 13 14 |
# File 'lib/session.rb', line 10 def bootstrap_settings(connection, controller) @connection = connection @ip_addr = @connection.peeraddr[-1] @controller = controller.new(self) end |
#start ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/session.rb', line 16 def start @input_thread = Thread.new(@connection) do |client| while (client_input = client.gets.chomp) @controller.get_text client_input end end end |