Class: DRbWebSocket::Server
- Inherits:
-
Object
- Object
- DRbWebSocket::Server
- Defined in:
- lib/drb_web_socket/server.rb
Overview
A protocol instance from DrbWebSocket::Protocol.open_server.
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Get the URI for this server.
Instance Method Summary collapse
-
#accept ⇒ Object
Accept a new connection to the server.
-
#close ⇒ Object
Close the server connection.
-
#initialize(uri, socket, config = {}) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(uri, socket, config = {}) ⇒ Server
Returns a new instance of Server.
9 10 11 12 13 14 15 |
# File 'lib/drb_web_socket/server.rb', line 9 def initialize(uri, socket, config = {}) raise ArgumentError, "socket Must respond to :to_io" unless socket.respond_to?(:to_io) @uri = uri @socket = socket @config = config end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Get the URI for this server.
7 8 9 |
# File 'lib/drb_web_socket/server.rb', line 7 def uri @uri end |
Instance Method Details
#accept ⇒ Object
Accept a new connection to the server. Returns a protocol instance capable of communicating with the client.
19 20 21 22 |
# File 'lib/drb_web_socket/server.rb', line 19 def accept socket = @socket.accept ConnectionToClient.new(@uri, socket, @config) end |
#close ⇒ Object
Close the server connection.
25 26 27 28 29 30 |
# File 'lib/drb_web_socket/server.rb', line 25 def close return unless @socket @socket.close @socket = nil end |