Module: Lively::Electron::Environment::Application
- Includes:
- Lively::Environment::Application
- Defined in:
- lib/lively/electron/environment.rb
Overview
The Lively environment for a desktop Electron shell that connects to this process over a local HTTP server. The server uses TCP and may inherit a bound socket passed via ‘LIVELY_SERVER_DESCRIPTOR`.
Instance Method Summary collapse
-
#endpoint ⇒ Object
The HTTP endpoint the server listens on.
-
#url ⇒ Object
The base URL the Electron shell uses to reach the Lively server.
Instance Method Details
#endpoint ⇒ Object
The HTTP endpoint the server listens on. When ‘LIVELY_SERVER_DESCRIPTOR` is set, reuses the inherited bound socket instead of binding a new one.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/lively/electron/environment.rb', line 31 def endpoint if descriptor = ENV["LIVELY_SERVER_DESCRIPTOR"] Console.info(self, "Using inherited file descriptor.", descriptor: descriptor) bound_socket = Socket.for_fd(descriptor.to_i) # Ensure the inherited socket is non-blocking: bound_socket.nonblock = true endpoint = IO::Endpoint::BoundEndpoint.new(nil, [bound_socket]) end Async::HTTP::Endpoint.parse(self.url, endpoint) end |
#url ⇒ Object
The base URL the Electron shell uses to reach the Lively server. Reads ‘LIVELY_URL` from the environment, or defaults to `localhost:0/`.
24 25 26 |
# File 'lib/lively/electron/environment.rb', line 24 def url ENV.fetch("LIVELY_URL", "http://localhost:0/") end |