Class: TED::Serverlet
- Inherits:
-
Object
- Object
- TED::Serverlet
- Defined in:
- lib/serverlet.rb
Instance Method Summary collapse
-
#initialize(ip = "localhost", port = 9017) ⇒ Serverlet
constructor
A new instance of Serverlet.
- #run ⇒ Object
Constructor Details
#initialize(ip = "localhost", port = 9017) ⇒ Serverlet
Returns a new instance of Serverlet.
5 6 7 8 9 10 11 12 |
# File 'lib/serverlet.rb', line 5 def initialize(ip="localhost", port=9017) @hub = TCPSocket.open("46.101.76.160", 9018) @server = TCPServer.open(ip, port) @resp = nil @game = nil run @resp.join end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/serverlet.rb', line 14 def run @resp = Thread.new do ## Handle all the messages coming in from the hub and act appropriatly loop{ msg = @hub.gets.chomp puts msg } end Thread.new(@server.accept) do |client| client.puts "Connected!" end end |