Class: IORequest::SSLSockets::Server
- Inherits:
-
Object
- Object
- IORequest::SSLSockets::Server
- Includes:
- Utility::MultiThread
- Defined in:
- lib/io_request/connection/ssl_sockets.rb
Overview
SSL socket server.
Instance Method Summary collapse
- #clients ⇒ Array<IORequest::Client>
-
#data(client) ⇒ Hash?
You are free to store anything you want in hash.
-
#initialize(port: 8000, authorizer: Authorizer.empty, certificate: nil, key: nil, &requests_handler) ⇒ Server
constructor
Initalize new server.
-
#start ⇒ Object
Start server.
-
#stop ⇒ Object
Fully stop server.
Constructor Details
#initialize(port: 8000, authorizer: Authorizer.empty, certificate: nil, key: nil, &requests_handler) ⇒ Server
Initalize new server.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/io_request/connection/ssl_sockets.rb', line 20 def initialize( port: 8000, authorizer: Authorizer.empty, certificate: nil, key: nil, &requests_handler ) @port = port @authorizer = @requests_handler = requests_handler initialize_ssl_context(certificate, key) end |
Instance Method Details
#clients ⇒ Array<IORequest::Client>
35 36 37 |
# File 'lib/io_request/connection/ssl_sockets.rb', line 35 def clients @clients_data.keys end |
#data(client) ⇒ Hash?
Returns you are free to store anything you want in hash. Only field you will find in it is ‘auth` with authenticator data.
42 43 44 |
# File 'lib/io_request/connection/ssl_sockets.rb', line 42 def data(client) @clients_data[client] end |
#start ⇒ Object
Start server.
47 48 49 50 51 52 53 |
# File 'lib/io_request/connection/ssl_sockets.rb', line 47 def start @clients_data = {} @server = TCPServer.new(@port) @accept_thread = in_thread(name: 'accept_thr') { accept_loop } end |
#stop ⇒ Object
Fully stop server.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/io_request/connection/ssl_sockets.rb', line 56 def stop clients.each(&:close) @clients_data.clear @server.close @server = nil @accept_thread&.kill @accept_thread = nil end |