Module: Lich::Main::DetachableClientNotice Private
- Defined in:
- documented/main/detachable_client_notice.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Builds the human-facing notices Lich prints to $stdout for detachable client listener lifecycle events: when the listener starts accepting connections and when an attached client drops.
These notices share a controlling terminal with an exec'd frontend (for example ProfanityFE launched by a wrapper script), so they only become visible once that frontend releases the screen. Keeping the wording in one pure formatter ensures the connect and disconnect paths stay symmetric and can be unit tested without opening sockets.
Constant Summary collapse
- PREFIX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'--- Lich: detachable client'
Class Method Summary collapse
-
.address(host, port) ⇒ String
private
Formats a "host:port" endpoint, bracketing IPv6 literals so the port is unambiguous (for example
[::1]:8000). -
.disconnected(name:, host:, port:, attached:) ⇒ String
private
Notice emitted when an attached client disconnects.
-
.listening(host:, port:) ⇒ String
private
Notice emitted when the detachable listener is ready for connections.
Class Method Details
.address(host, port) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Formats a "host:port" endpoint, bracketing IPv6 literals so the port is
unambiguous (for example [::1]:8000). A host that is already bracketed
is left as-is.
33 34 35 36 37 |
# File 'documented/main/detachable_client_notice.rb', line 33 def self.address(host, port) formatted_host = host.to_s formatted_host = "[#{formatted_host}]" if formatted_host.include?(':') && !formatted_host.start_with?('[') "#{formatted_host}:#{port}" end |
.disconnected(name:, host:, port:, attached:) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Notice emitted when an attached client disconnects. Includes the session name so an operator can tell which character's frontend dropped, the endpoint it was attached to, and how many clients remain attached.
58 59 60 61 |
# File 'documented/main/detachable_client_notice.rb', line 58 def self.disconnected(name:, host:, port:, attached:) subject = name.to_s.empty? ? PREFIX : "#{PREFIX} #{name}" "#{subject} disconnected from #{address(host, port)} (#{attached} attached)" end |
.listening(host:, port:) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Notice emitted when the detachable listener is ready for connections.
44 45 46 |
# File 'documented/main/detachable_client_notice.rb', line 44 def self.listening(host:, port:) "#{PREFIX} listening on #{address(host, port)}" end |