Class: LocalMessageRouter
- Inherits:
-
Object
- Object
- LocalMessageRouter
- Defined in:
- lib/local_message/local_message_router.rb
Instance Attribute Summary collapse
-
#open_ports ⇒ Object
readonly
Returns the value of attribute open_ports.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#registered_users ⇒ Object
readonly
Returns the value of attribute registered_users.
Instance Method Summary collapse
-
#initialize(listening_port) ⇒ LocalMessageRouter
constructor
A new instance of LocalMessageRouter.
- #start ⇒ Object
Constructor Details
#initialize(listening_port) ⇒ LocalMessageRouter
Returns a new instance of LocalMessageRouter.
7 8 9 10 |
# File 'lib/local_message/local_message_router.rb', line 7 def initialize(listening_port) @port = listening_port @registered_users = {} end |
Instance Attribute Details
#open_ports ⇒ Object (readonly)
Returns the value of attribute open_ports.
5 6 7 |
# File 'lib/local_message/local_message_router.rb', line 5 def open_ports @open_ports end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/local_message/local_message_router.rb', line 5 def port @port end |
#registered_users ⇒ Object (readonly)
Returns the value of attribute registered_users.
5 6 7 |
# File 'lib/local_message/local_message_router.rb', line 5 def registered_users @registered_users end |
Instance Method Details
#start ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/local_message/local_message_router.rb', line 12 def start server = TCPServer.open(port) begin Thread.start(server.accept) do |client| fam, port, hostname, ip = client.peeraddr = client.read handle(, port, ip) client.close end end while true end |