3 Commits

2 changed files with 5 additions and 4 deletions

View File

@@ -60,15 +60,15 @@ class W3DHub
end end
# Handle arbitrary urls that may come through # Handle arbitrary urls that may come through
url = nil
if path.start_with?("http") if path.start_with?("http")
uri = URI(path) uri = URI(path)
endpoint = uri.origin endpoint = uri.origin
path = uri.request_uri path = uri.request_uri
else
url = "#{endpoint}#{path}"
end end
url = "#{endpoint}#{path}"
logger.debug(LOG_TAG) { "Fetching #{method.to_s.upcase} \"#{url}\"..." } logger.debug(LOG_TAG) { "Fetching #{method.to_s.upcase} \"#{url}\"..." }
# Inject Authorization header if account data is populated # Inject Authorization header if account data is populated

View File

@@ -255,13 +255,14 @@ class W3DHub
!server.status.password && !server.status.password &&
server.status.player_count < server.status.max_players server.status.player_count < server.status.max_players
end end
server_options.sort_by! { |s| [s.status.player_count, s.ping] }.reverse!
# try to find server with lowest ping and matching version # try to find server with lowest ping and matching version
found_server = server_options.find { |server| server.version == app_data[:installed_version] } found_server = server_options.find { |server| server.version == app_data[:installed_version] }
# try to find server with lowest ping and undefined version # try to find server with lowest ping and undefined version
found_server ||= server_options.find { |server| server.version == Api::ServerListServer::NO_OR_DEFAULT_VERSION } found_server ||= server_options.find { |server| server.version == Api::ServerListServer::NO_OR_DEFAULT_VERSION }
found_server ? found_server : nil found_server || nil
end end
def play_now(app_id, channel) def play_now(app_id, channel)