mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-03-22 04:06:18 +00:00
Initial work on PingManager
This commit is contained in:
@@ -20,8 +20,12 @@ class W3DHub
|
||||
|
||||
@status = Status.new(@data[:status])
|
||||
|
||||
@ping_interval = 30_000
|
||||
# if we're on unix and using the PingManager then check every second since
|
||||
# we're not _actually_ pinging the server.
|
||||
@ping_interval = W3DHub.unix? ? 1_000 : 60_000
|
||||
@last_pinged = Gosu.milliseconds + @ping_interval + 1_000
|
||||
|
||||
Store.ping_manager.add_address(@address)
|
||||
end
|
||||
|
||||
def update(hash)
|
||||
@@ -49,6 +53,16 @@ class W3DHub
|
||||
if force_ping || Gosu.milliseconds - @last_pinged >= @ping_interval
|
||||
@last_pinged = Gosu.milliseconds
|
||||
|
||||
if W3DHub.unix?
|
||||
average_ping = Store.ping_manager.ping_for(@address)
|
||||
|
||||
@ping = average_ping.negative? ? NO_OR_BAD_PING : average_ping
|
||||
|
||||
States::Interface.instance&.update_server_ping(self)
|
||||
end
|
||||
|
||||
return unless W3DHub.windows?
|
||||
|
||||
W3DHub::BackgroundWorker.foreground_parallel_job(
|
||||
lambda do
|
||||
W3DHub.command("ping #{@address} #{W3DHub.windows? ? '-n 3' : '-c 3'}") do |line|
|
||||
|
||||
Reference in New Issue
Block a user