Module: UnixSocks::ServerShared
- Included in:
- DomainSocketServer, TCPSocketServer
- Defined in:
- lib/unix_socks/server_shared.rb
Overview
Shared server functionality for UnixSocks implementations
This module provides common methods for transmitting messages and parsing JSON responses that are used by both Unix domain socket and TCP socket server implementations.
Instance Method Summary collapse
-
#to_uri ⇒ URI
Converts the server’s URL representation into a URI object.
-
#transmit_with_response(message, close: true) ⇒ Hash?
Sends a message and returns the parsed JSON response.
Instance Method Details
#to_uri ⇒ URI
Converts the server’s URL representation into a URI object.
This method takes the URL string returned by #to_url and parses it into a URI object for convenient access to the server’s address components.
24 25 26 |
# File 'lib/unix_socks/server_shared.rb', line 24 def to_uri URI.parse(to_url) end |
#transmit_with_response(message, close: true) ⇒ Hash?
Sends a message and returns the parsed JSON response.
11 12 13 14 15 16 |
# File 'lib/unix_socks/server_shared.rb', line 11 def transmit_with_response(, close: true) socket = transmit(, close: false) (socket.gets, socket) ensure close and socket&.close end |