This commit is contained in:
2026-06-22 10:55:51 -05:00
parent 0eb188f72e
commit 675ab3b1a8
2 changed files with 58 additions and 22 deletions

View File

@@ -28,24 +28,12 @@ module W3DHubLauncher
query = Ractor.receive
pp query
case query.type
when Request::FETCH_URL
when Request::DOWNLOAD_URL
when Request::W3DHUB_API_CALL
if respond_to?(query.type)
Async do
result = @w3dhub_api.send(query.data[:call], *(query.data[:arguments] || []))
response = Response.new(result.okay? ? Request::STATUS_COMPLETE : Request::STATUS_ERROR, query.request_id, result)
Ractor.main.send(response)
send(query.type, query)
end
when Request::LAUNCHER_UPDATE_SETTINGS
result = CyberarmEngine::Result.new
FileUtils.mkdir_p(W3DHubLauncher::CONFIG_PATH) # FAILABLE!
File.write("#{W3DHubLauncher::CONFIG_PATH}/settings.json", query.data) # FAILABLE!
result.data = query.data
response = Response.new(result.okay? ? Request::STATUS_COMPLETE : Request::STATUS_ERROR, query.request_id, result)
Ractor.main.send(response)
else
raise "UNKNOWN REQUEST"
raise "UNKNOWN REQUEST: #{query}"
end
end
end
@@ -55,5 +43,47 @@ module W3DHubLauncher
def backend_websocket
end
#
# ------------ query / request handlers ------------
#
def fetch_url(query)
end
def download_url(query)
end
def w3dhub_api_call(query)
result = @w3dhub_api.send(query.data[:call], *(query.data[:arguments] || []))
response = Response.new(result.okay? ? Request::STATUS_COMPLETE : Request::STATUS_ERROR, query.request_id, result)
Ractor.main.send(response)
end
def update_settings(query)
result = CyberarmEngine::Result.new
FileUtils.mkdir_p(W3DHubLauncher::CONFIG_PATH) # FIXME: FAILABLE!
File.write("#{W3DHubLauncher::CONFIG_PATH}/settings.json", query.data) # FIXME: FAILABLE!
result.data = query.data
response = Response.new(result.okay? ? Request::STATUS_COMPLETE : Request::STATUS_ERROR, query.request_id, result)
Ractor.main.send(response)
end
def install_application(query)
end
def update_application(query)
end
def repair_application(query)
end
def move_application(query)
end
def uninstall_application(query)
end
end
end

View File

@@ -23,7 +23,7 @@ module W3DHubLauncher
# write updated launcher settings
def self.update_settings(settings, &block)
Worker::Request.new(Request::LAUNCHER_UPDATE_SETTINGS, settings.to_json, &block)
Worker::Request.new(:update_settings, settings.to_json, &block)
end
# returns list of available applications
@@ -37,37 +37,43 @@ module W3DHubLauncher
end
# returns news for application
def self.news
def self.news(category = "launcher-home", &block)
Worker::Request.new(:news, category, &block)
end
# returns news for application
def self.events(app_id, &block)
Worker::Request.new(:events, app_id, &block)
end
# request installation of application
#
# periodically reports progress until completion
def self.install_application
def self.install_application(app_id, channel_id)
end
# request update of application
#
# periodically reports progress until completion
def self.update_application
def self.update_application(app_id, channel_id)
end
# request repair of application
#
# periodically reports progress until completion
def self.repair_application
def self.repair_application(app_id, channel_id)
end
# request relocation of application
#
# periodically reports progress until completion
def self.move_application
def self.move_application(app_id, channel_id)
end
# request removal of application
#
# periodically reports progress until completion
def self.uninstall_application
def self.uninstall_application(app_id, channel_id)
end
end
end