Class: GQTP::Backend::Coolio::Server
- Inherits:
-
Object
- Object
- GQTP::Backend::Coolio::Server
- Defined in:
- lib/gqtp/backend/coolio.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Server
Returns a new instance of Server.
111 112 113 114 115 116 |
# File 'lib/gqtp/backend/coolio.rb', line 111 def initialize(={}) @options = @host = [:host] || "0.0.0.0" @port = [:port] || 10043 @loop = [:loop] || ::Coolio::Loop.default end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
110 111 112 |
# File 'lib/gqtp/backend/coolio.rb', line 110 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
110 111 112 |
# File 'lib/gqtp/backend/coolio.rb', line 110 def port @port end |
Instance Method Details
#run ⇒ Object
118 119 120 121 122 123 124 125 |
# File 'lib/gqtp/backend/coolio.rb', line 118 def run @server = ::Coolio::TCPServer.new(@host, @port, Socket) do |client| yield(client) end @server.attach(@loop) @loop.run Request.new(@loop) end |
#shutdown ⇒ Object
127 128 129 |
# File 'lib/gqtp/backend/coolio.rb', line 127 def shutdown @server.close end |