Compare commits

...

4 Commits

Author SHA1 Message Date
8972561f5f Improvements to server list updater, iirc. 2023-05-27 09:35:40 -05:00
51aaf12971 Update gems 2023-05-27 09:35:08 -05:00
d07395c7f0 Style fix 2023-05-27 09:34:54 -05:00
9b8d13929d Fixed always repainting due to Boot state not popping 2023-05-27 09:34:25 -05:00
4 changed files with 40 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
concurrent-ruby (1.2.0) concurrent-ruby (1.2.2)
cyberarm_engine (0.23.0) cyberarm_engine (0.23.0)
excon (~> 0.88) excon (~> 0.88)
gosu (~> 1.1) gosu (~> 1.1)
@@ -13,16 +13,16 @@ GEM
ffi (1.15.5) ffi (1.15.5)
ffi-win32-extensions (1.0.4) ffi-win32-extensions (1.0.4)
ffi ffi
gosu (1.4.5) gosu (1.4.6)
gosu_more_drawables (0.3.1) gosu_more_drawables (0.3.1)
i18n (1.12.0) i18n (1.13.0)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
ircparser (1.0.0) ircparser (1.0.0)
rake (13.0.6) rake (13.0.6)
rexml (3.2.5) rexml (3.2.5)
rubyzip (2.3.2) rubyzip (2.3.2)
websocket (1.2.9) websocket (1.2.9)
websocket-client-simple (0.6.0) websocket-client-simple (0.6.1)
event_emitter event_emitter
websocket websocket
win32-process (0.10.0) win32-process (0.10.0)
@@ -48,4 +48,4 @@ DEPENDENCIES
win32-security win32-security
BUNDLED WITH BUNDLED WITH
2.4.3 2.4.13

View File

@@ -9,7 +9,7 @@ class W3DHub
@games = [] @games = []
games.each { |hash| @games << Game.new(hash) } games.each { |hash| @games << Game.new(hash) }
@games.sort_by! { |a| a.name }.reverse @games.sort_by!(&:name).reverse
end end
def games def games

View File

@@ -11,7 +11,11 @@ class W3DHub
@@instance = ServerListUpdater.new @@instance = ServerListUpdater.new
end end
attr_accessor :auto_reconnect
def initialize def initialize
@auto_reconnect = false
logger.info(LOG_TAG) { "Starting emulated SignalR Server List Updater..." } logger.info(LOG_TAG) { "Starting emulated SignalR Server List Updater..." }
run run
end end
@@ -20,6 +24,11 @@ class W3DHub
Thread.new do Thread.new do
begin begin
connect connect
while W3DHub::BackgroundWorker.alive?
connect if @auto_reconnect
sleep 1
end
rescue => e rescue => e
puts e puts e
puts e.backtrace puts e.backtrace
@@ -34,7 +43,7 @@ class W3DHub
end end
def connect def connect
auto_reconnect = false @auto_reconnect = false
logger.debug(LOG_TAG) { "Requesting connection token..." } logger.debug(LOG_TAG) { "Requesting connection token..." }
response = Excon.post("https://gsh.w3dhub.com/listings/push/v2/negotiate?negotiateVersion=1", headers: Api::DEFAULT_HEADERS, body: "") response = Excon.post("https://gsh.w3dhub.com/listings/push/v2/negotiate?negotiateVersion=1", headers: Api::DEFAULT_HEADERS, body: "")
@@ -44,7 +53,21 @@ class W3DHub
endpoint = "https://gsh.w3dhub.com/listings/push/v2?id=#{id}" endpoint = "https://gsh.w3dhub.com/listings/push/v2?id=#{id}"
logger.debug(LOG_TAG) { "Connecting to websocket..." } logger.debug(LOG_TAG) { "Connecting to websocket..." }
this = self
WebSocket::Client::Simple.connect(endpoint, headers: Api::DEFAULT_HEADERS) do |ws| WebSocket::Client::Simple.connect(endpoint, headers: Api::DEFAULT_HEADERS) do |ws|
ws.on(:open) do
logger.debug(LOG_TAG) { "Requesting json protocol, v1..." }
ws.send({ protocol: "json", version: 1 }.to_json + "\x1e")
logger.debug(LOG_TAG) { "Subscribing to server changes..." }
Store.server_list.each_with_index do |server, i|
i += 1
mode = 1 # 2 full details, 1 basic details
out = { "type": 1, "invocationId": "#{i}", "target": "SubscribeToServerStatusUpdates", "arguments": [server.id, mode] }
ws.send(out.to_json + "\x1e")
end
end
ws.on(:message) do |msg| ws.on(:message) do |msg|
msg = msg.data.split("\x1e").first msg = msg.data.split("\x1e").first
@@ -60,37 +83,25 @@ class W3DHub
id, data = hash[:arguments] id, data = hash[:arguments]
server = Store.server_list.find { |s| s.id == id } server = Store.server_list.find { |s| s.id == id }
server_updated = server&.update(data) server_updated = server&.update(data)
States::Interface.instance&.update_server_browser(server) if server_updated
BackgroundWorker.foreground_job(-> {}, ->(result){ States::Interface.instance&.update_server_browser(server) }) if server_updated
end end
end end
end end
end end
ws.on(:open) do
logger.debug(LOG_TAG) { "Requesting json protocol, v1..." }
ws.send({ protocol: "json", version: 1 }.to_json + "\x1e")
logger.debug(LOG_TAG) { "Subscribing to server changes..." }
Store.server_list.each_with_index do |server, i|
i += 1
mode = 1 # 2 full details, 1 basic details
out = { "type": 1, "invocationId": "#{i}", "target": "SubscribeToServerStatusUpdates", "arguments": [server.id, mode] }
ws.send(out.to_json + "\x1e")
end
end
ws.on(:close) do |e| ws.on(:close) do |e|
p e p e
auto_reconnect = true this.auto_reconnect = true
ws.close
end end
ws.on(:error) do |e| ws.on(:error) do |e|
p e p e
auto_reconnect = true this.auto_reconnect = true
ws.close
end end
end end
connect if auto_reconnect
end end
end end
end end

View File

@@ -56,7 +56,10 @@ class W3DHub
load_offline_applications_list if @offline_mode load_offline_applications_list if @offline_mode
push_state(States::Interface) if @offline_mode || (@progressbar.value >= 1.0 && @task_index == @tasks.size) if @offline_mode || (@progressbar.value >= 1.0 && @task_index == @tasks.size)
pop_state
push_state(States::Interface)
end
return if @offline_mode return if @offline_mode