mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-08-04 21:31:22 +00:00
Sync
This commit is contained in:
@@ -55,6 +55,7 @@ module W3DHubLauncher
|
||||
|
||||
def w3dhub_api_call(query)
|
||||
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)
|
||||
|
||||
Ractor.main.send(response)
|
||||
|
||||
@@ -32,21 +32,21 @@ module W3DHubLauncher
|
||||
|
||||
Sync do |task|
|
||||
task.with_timeout(API_TIMEOUT) do
|
||||
endpoint = Async::HTTP::Endpoint.parse(url)
|
||||
client = @http_clients[endpoint.hostname.downcase] ||= Async::HTTP::Client.new(endpoint)
|
||||
|
||||
pp endpoint, endpoint.authority, client
|
||||
response = client.get(endpoint.path)
|
||||
pp response
|
||||
# client.send(method, endpoint.path, headers, body) do |response|
|
||||
# result.data = response.read
|
||||
# rescue StandardError => e
|
||||
# result.error = e
|
||||
# end
|
||||
# rescue Async::TimeoutError
|
||||
# result.error = e
|
||||
Async::HTTP::Internet.send(method, url, headers, body) do |response|
|
||||
if response.success?
|
||||
result.data = response.read
|
||||
else
|
||||
result.error = true
|
||||
end
|
||||
end
|
||||
rescue StandardError => e
|
||||
result.error = e
|
||||
rescue Async::TimeoutError => e
|
||||
result.error = e
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
@@ -103,6 +103,9 @@ module W3DHubLauncher
|
||||
alternate_result = fetch("#{ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-applications")
|
||||
|
||||
pp [primary_result, alternate_result]
|
||||
|
||||
# FIXME: Merge primary and alternate results
|
||||
result
|
||||
end
|
||||
|
||||
def fetch_news()
|
||||
|
||||
@@ -65,9 +65,9 @@ Thread.new do
|
||||
end
|
||||
|
||||
# 10.times do
|
||||
# W3DHubLauncher::Worker::Request.new(W3DHubLauncher::Worker::Request::W3DHUB_API_CALL, { call: :fetch_applications }) do |result|
|
||||
# pp result
|
||||
# end
|
||||
W3DHubLauncher::Worker::Request.new(:w3dhub_api_call, { call: :fetch_applications }) do |result|
|
||||
pp result
|
||||
end
|
||||
# end
|
||||
|
||||
window = W3DHubLauncher::Window.new(width: 1280, height: 800, resizable: true)
|
||||
|
||||
Reference in New Issue
Block a user