Only Initialize the stat tracker once, and explicitly set timeout to 5 seconds.
This commit is contained in:
parent
b2abf89432
commit
f4c332ab2f
2 changed files with 15 additions and 4 deletions
|
|
@ -11,10 +11,20 @@ namespace TShockAPI
|
|||
{
|
||||
public class StatTracker
|
||||
{
|
||||
private bool failed = false;
|
||||
private bool failed;
|
||||
private bool initialized;
|
||||
public StatTracker()
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(SendUpdate);
|
||||
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
initialized = true;
|
||||
ThreadPool.QueueUserWorkItem(SendUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
private HttpWebResponse GetResponseNoException(HttpWebRequest req)
|
||||
|
|
@ -51,6 +61,7 @@ namespace TShockAPI
|
|||
var encoded = HttpUtility.UrlEncode(serialized);
|
||||
var uri = String.Format("http://96.47.231.227:8000?data={0}", encoded);
|
||||
var client = (HttpWebRequest)WebRequest.Create(uri);
|
||||
client.Timeout = 5000;
|
||||
try
|
||||
{
|
||||
using (var resp = GetResponseNoException(client))
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ namespace TShockAPI
|
|||
public static SecureRest RestApi;
|
||||
public static RestManager RestManager;
|
||||
public static Utils Utils = Utils.Instance;
|
||||
public static StatTracker StatTracker;
|
||||
public static StatTracker StatTracker = new StatTracker();
|
||||
/// <summary>
|
||||
/// Used for implementing REST Tokens prior to the REST system starting up.
|
||||
/// </summary>
|
||||
|
|
@ -599,7 +599,7 @@ namespace TShockAPI
|
|||
|
||||
ComputeMaxStyles();
|
||||
FixChestStacks();
|
||||
StatTracker = new StatTracker();
|
||||
StatTracker.Initialize();
|
||||
}
|
||||
|
||||
private void ComputeMaxStyles()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue