This commit is contained in:
2026-06-30 19:48:48 -05:00
parent 02cbd215f5
commit c6ee9eab31
3 changed files with 20 additions and 16 deletions

View File

@@ -55,6 +55,7 @@ module W3DHubLauncher
def w3dhub_api_call(query) def w3dhub_api_call(query)
result = @w3dhub_api.send(query.data[:call], *(query.data[:arguments] || [])) result = @w3dhub_api.send(query.data[:call], *(query.data[:arguments] || []))
pp result
response = Response.new(result.okay? ? Request::STATUS_COMPLETE : Request::STATUS_ERROR, query.request_id, result) response = Response.new(result.okay? ? Request::STATUS_COMPLETE : Request::STATUS_ERROR, query.request_id, result)
Ractor.main.send(response) Ractor.main.send(response)

View File

@@ -32,20 +32,20 @@ module W3DHubLauncher
Sync do |task| Sync do |task|
task.with_timeout(API_TIMEOUT) do task.with_timeout(API_TIMEOUT) do
endpoint = Async::HTTP::Endpoint.parse(url) Async::HTTP::Internet.send(method, url, headers, body) do |response|
client = @http_clients[endpoint.hostname.downcase] ||= Async::HTTP::Client.new(endpoint) if response.success?
result.data = response.read
pp endpoint, endpoint.authority, client else
response = client.get(endpoint.path) result.error = true
pp response end
# client.send(method, endpoint.path, headers, body) do |response| end
# result.data = response.read rescue StandardError => e
# rescue StandardError => e result.error = e
# result.error = e rescue Async::TimeoutError => e
# end result.error = e
# rescue Async::TimeoutError
# result.error = e
end end
result
end end
result result
@@ -103,6 +103,9 @@ module W3DHubLauncher
alternate_result = fetch("#{ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications") alternate_result = fetch("#{ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications")
pp [primary_result, alternate_result] pp [primary_result, alternate_result]
# FIXME: Merge primary and alternate results
result
end end
def fetch_news() def fetch_news()

View File

@@ -65,9 +65,9 @@ Thread.new do
end end
# 10.times do # 10.times do
# W3DHubLauncher::Worker::Request.new(W3DHubLauncher::Worker::Request::W3DHUB_API_CALL, { call: :fetch_applications }) do |result| W3DHubLauncher::Worker::Request.new(:w3dhub_api_call, { call: :fetch_applications }) do |result|
# pp result pp result
# end end
# end # end
window = W3DHubLauncher::Window.new(width: 1280, height: 800, resizable: true) window = W3DHubLauncher::Window.new(width: 1280, height: 800, resizable: true)