///// <summary> ///// Used to construct a consistent id, meerly to detect multiple servers on the same IP (e.g. different port) ///// </summary> ///// <returns></returns> //static string ConstructUUID() //{ // var str = String.Empty; // str += Terraria.Netplay.serverPort; // str += Environment.MachineName; // using (var hasher = new SHA256Managed()) // { // var output = hasher.ComputeHash(Encoding.UTF8.GetBytes(str)); // return BitConverter.ToString(output).Replace("-", String.Empty); // } //} public static void Begin(int coreBuild) { #if ENABLED if (_timer == null) { _coreBuild = coreBuild; _timer = new System.Timers.Timer(1000 * 60 * MinuteInterval); var callback = new System.Timers.ElapsedEventHandler((e, a) => { if (Enabled) { Beat(); } }); _timer.Elapsed += callback; _timer.Start(); callback.BeginInvoke(null, null, new AsyncCallback((result) => { (result.AsyncState as System.Timers.ElapsedEventHandler).EndInvoke(result); }), callback); Enabled = true; } else if (!_timer.Enabled) { _timer.Enabled = true; } #endif }
///// <summary> ///// Used to construct a consistent id, meerly to detect multiple servers on the same IP (e.g. different port) ///// </summary> ///// <returns></returns> //static string ConstructUUID() //{ // var str = String.Empty; // str += Terraria.Netplay.serverPort; // str += Environment.MachineName; // using (var hasher = new SHA256Managed()) // { // var output = hasher.ComputeHash(Encoding.UTF8.GetBytes(str)); // return BitConverter.ToString(output).Replace("-", String.Empty); // } //} public static void Begin(int coreBuild) { #if ENABLED if (_timer == null) { _coreBuild = coreBuild; _timer = new System.Timers.Timer(1000 * 60 * MinuteInterval); var callback = new System.Timers.ElapsedEventHandler((e, a) => { if (Enabled) { Beat(); } }); _timer.Elapsed += callback; _timer.Start(); callback.BeginInvoke(null, null, new AsyncCallback((result) => { (result.AsyncState as System.Timers.ElapsedEventHandler).EndInvoke(result); }), callback); Enabled = true; if (PublishToList && String.IsNullOrEmpty(ServerName)) { ProgramLog.Error.Log("The server was instructed to be published but no server name was specified"); } } else if (!_timer.Enabled) { _timer.Enabled = true; } #endif }
///// <summary> ///// Used to construct a consistent id, meerly to detect multiple servers on the same IP (e.g. different port) ///// </summary> ///// <returns></returns> //static string ConstructUUID() //{ // var str = String.Empty; // str += Terraria.Netplay.serverPort; // str += Environment.MachineName; // using (var hasher = new SHA256Managed()) // { // var output = hasher.ComputeHash(Encoding.UTF8.GetBytes(str)); // return BitConverter.ToString(output).Replace("-", String.Empty); // } //} public static void Begin(int coreBuild) { #if ENABLED if (_timer == null) { _coreBuild = coreBuild; _timer = new System.Timers.Timer(1000 * 60 * MinuteInterval); var callback = new System.Timers.ElapsedEventHandler((e, a) => { if (Enabled) Beat(); }); _timer.Elapsed += callback; _timer.Start(); callback.BeginInvoke(null, null, new AsyncCallback((result) => { (result.AsyncState as System.Timers.ElapsedEventHandler).EndInvoke(result); }), callback); Enabled = true; if (PublishToList && String.IsNullOrEmpty(ServerName)) { ProgramLog.Error.Log("The server was instructed to be published but no server name was specified"); } } else if (!_timer.Enabled) _timer.Enabled = true; #endif }
///// <summary> ///// Used to construct a consistent id, meerly to detect multiple servers on the same IP (e.g. different port) ///// </summary> ///// <returns></returns> //static string ConstructUUID() //{ // var str = String.Empty; // str += Terraria.Netplay.serverPort; // str += Environment.MachineName; // using (var hasher = new SHA256Managed()) // { // var output = hasher.ComputeHash(Encoding.UTF8.GetBytes(str)); // return BitConverter.ToString(output).Replace("-", String.Empty); // } //} public static void Begin(int coreBuild) { #if ENABLED if (_timer == null) { _coreBuild = coreBuild; _timer = new System.Timers.Timer(1000 * 60 * MinuteInterval); var callback = new System.Timers.ElapsedEventHandler((e, a) => { if (Enabled) Beat(); }); _timer.Elapsed += callback; _timer.Start(); callback.BeginInvoke(null, null, new AsyncCallback((result) => { (result.AsyncState as System.Timers.ElapsedEventHandler).EndInvoke(result); }), callback); Enabled = true; } else if (!_timer.Enabled) _timer.Enabled = true; #endif }
public override void StartUpdateDownloads(double updatePeriod) { if (!_updateTimer.Enabled) { // Add random factor to protect against DOS errors _updateTimer.Interval = updatePeriod + _randomGen.Next(-1000, 1000); _updateTimer.Start(); _timerEvent += new System.Timers.ElapsedEventHandler(Timer_Elapsed); _timerEvent.BeginInvoke(null, null, null, null); } else { //Already updating ... Ignore request. } }