Class: Ubiquity::Server
- Inherits:
-
Object
- Object
- Ubiquity::Server
- Defined in:
- lib/ubiquity/protocol.rb
Instance Method Summary collapse
-
#initialize(port = 1978) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(port = 1978) ⇒ Server
Returns a new instance of Server.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ubiquity/protocol.rb', line 23 def initialize port=1978 @scope = {} server = TCPServer.new port puts "Ubiquity server listening on port 0.0.0.0:#{port}" $client = server.accept while line = $client.gets block = JSON.parse(line) c = eval(block["cmd"]) c.call @scope, self end $client.close end |