Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Shared/PlasmaDownloader/ChobbylaHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,21 @@ public static bool DownloadUrl(this PlasmaDownloader downloader,
}


// News is optional. Do not hold the game start when the server does not answer
// (the HttpClient default is 100 s, and Mono does not apply it to the TCP connect).
static readonly TimeSpan PublicCommunityInfoTimeout = TimeSpan.FromSeconds(10);

public static bool UpdatePublicCommunityInfo(this PlasmaDownloader downloader, IChobbylaProgress progress)
{
try
{
progress.Status = "Loading community news";
var folder = Path.Combine(downloader.SpringPaths.WritableDirectory, "news");
if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);
var info = GlobalConst.GetContentService().Query(new GetPublicCommunityInfo());
// Run on the thread pool, so the query never needs the calling (UI) thread to finish.
var query = Task.Run(() => GlobalConst.GetContentService().QueryAsync(new GetPublicCommunityInfo()));
if (!query.Wait(PublicCommunityInfoTimeout)) throw new TimeoutException($"No answer from server in {PublicCommunityInfoTimeout.TotalSeconds} s");
Comment thread
Licho1 marked this conversation as resolved.
Resolved
var info = query.Result;
File.WriteAllText(Path.Combine(folder, "community.json"), JsonConvert.SerializeObject(info));
return true;
}
Expand Down
Loading