Skip to content

Commit

Permalink
Improved threading for server lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
BigETI committed Dec 15, 2018
1 parent c43e068 commit a98b982
Show file tree
Hide file tree
Showing 18 changed files with 3,319 additions and 3,264 deletions.
Binary file modified .vs/SAMPLauncherNET/v15/.suo
Binary file not shown.
4 changes: 2 additions & 2 deletions SAMPLauncherNET/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.6.3")]
[assembly: AssemblyFileVersion("1.0.6.3")]
[assembly: AssemblyVersion("1.0.6.4")]
[assembly: AssemblyFileVersion("1.0.6.4")]
9 changes: 6 additions & 3 deletions SAMPLauncherNET/SAMPLauncherNET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\APIDataContract.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\BackendRESTfulServer.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\BackendRESTfulServerDataContract.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\SAMPAPIServer.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\SAMPAPIServerDataContract.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\ChatlogFormatter.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\DeveloperToolsConfigDataContract.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\EChatlogFormatType.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\EPluginProvider.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\ERequestType.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\ERequestResponseType.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\EServerListType.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\EUpdateFrequency.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\FavouriteDataContract.cs" />
Expand Down Expand Up @@ -179,7 +179,9 @@
<Compile Include="Source\SAMPLauncherNET\Core\SAMPProvider.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\SAMPVersionDataContract.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\Server.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\ServerListEntry.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\ServerListConnector.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\ServerResponseDelegate.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\Session.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\SessionDataContract.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\SessionProvider.cs" />
Expand Down Expand Up @@ -294,6 +296,7 @@
<EmbeddedResource Include="Languages\es-419.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>es-419.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Languages\pt-PT.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
namespace SAMPLauncherNET
{
/// <summary>
/// Request type enumerator
/// Request or response type enumerator
/// </summary>
public enum ERequestType
public enum ERequestResponseType
{
/// <summary>
/// Ping
Expand All @@ -31,11 +31,6 @@ public enum ERequestType
/// <summary>
/// Detailed clients
/// </summary>
DetailedClients,

/// <summary>
/// Number of items in this enumerator
/// </summary>
NumOfItems
DetailedClients
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public FavouriteServer(string ipAddressAndPortString, string cachedHostname, str
gamemode = cachedGamemode;
this.serverPassword = serverPassword;
this.rconPassword = rconPassword;
FetchDataAsync(ERequestType.Ping);
FetchDataAsync(ERequestType.Information);
FetchDataAsync(ERequestResponseType.Ping);
FetchDataAsync(ERequestResponseType.Information);
}

/// <summary>
Expand All @@ -78,8 +78,8 @@ public FavouriteServer(FavouriteDataContract fdc) : base(fdc.Host, false)
}
serverPassword = "";
rconPassword = "";
FetchDataAsync(ERequestType.Ping);
FetchDataAsync(ERequestType.Information);
FetchDataAsync(ERequestResponseType.Ping);
FetchDataAsync(ERequestResponseType.Information);
}
}
}
34 changes: 17 additions & 17 deletions SAMPLauncherNET/Source/SAMPLauncherNET/Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,29 +173,29 @@ static void Main()
else
{
#endif
try
try
{
Translator.TranslatorInterface = new TranslatorInterface();
if (IsSAMPInstalled)
{
Translator.TranslatorInterface = new TranslatorInterface();
if (IsSAMPInstalled)
{
if (!Directory.Exists(ConfigPath + "\\screens"))
{
Directory.CreateDirectory(ConfigPath + "\\screens");
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
else
if (!Directory.Exists(ConfigPath + "\\screens"))
{
LaunchLatestSAMPInstaller();
Directory.CreateDirectory(ConfigPath + "\\screens");
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
catch (Exception e)
else
{
Console.Error.WriteLine(e);
MessageBox.Show("A fatal error has occured:\r\n\r\n" + e.Message, "Fatal error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
LaunchLatestSAMPInstaller();
}
}
catch (Exception e)
{
Console.Error.WriteLine(e);
MessageBox.Show("A fatal error has occured:\r\n\r\n" + e.Message, "Fatal error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#if !DEBUG
}
if (installerPath != null)
Expand Down
17 changes: 11 additions & 6 deletions SAMPLauncherNET/Source/SAMPLauncherNET/Core/RequestsRequired.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace SAMPLauncherNET
/// </summary>
public class RequestsRequired
{
/// <summary>
/// Request type count
/// </summary>
private static readonly int requestTypeCount = Enum.GetValues(typeof(ERequestResponseType)).Length;

/// <summary>
/// Values
/// </summary>
Expand All @@ -35,7 +40,7 @@ public class RequestsRequired
/// </summary>
/// <param name="requestType">Request type</param>
/// <returns>Request required</returns>
public bool this[ERequestType requestType]
public bool this[ERequestResponseType requestType]
{
get
{
Expand All @@ -55,7 +60,7 @@ public bool this[ERequestType requestType]
/// </summary>
/// <param name="requestType">Request type</param>
/// <returns>Operation code</returns>
public static char GetOpCode(ERequestType requestType)
public static char GetOpCode(ERequestResponseType requestType)
{
return opCodes[(int)requestType];
}
Expand All @@ -68,7 +73,7 @@ public RequestsRequired(bool initialValue)
{
int i;
DateTime now = DateTime.Now;
values = new bool[(int)(ERequestType.NumOfItems)];
values = new bool[requestTypeCount];
lastRequestTime = new DateTime[values.Length];
available = new bool[values.Length];
for (i = 0; i < values.Length; i++)
Expand All @@ -84,7 +89,7 @@ public RequestsRequired(bool initialValue)
/// </summary>
/// <param name="requestType">Request type</param>
/// <returns>Last request time</returns>
public DateTime GetLastRequestTime(ERequestType requestType)
public DateTime GetLastRequestTime(ERequestResponseType requestType)
{
return lastRequestTime[(int)requestType];
}
Expand All @@ -93,7 +98,7 @@ public DateTime GetLastRequestTime(ERequestType requestType)
/// Set last request time
/// </summary>
/// <param name="requestType">Request type</param>
public void SetLastRequestTime(ERequestType requestType)
public void SetLastRequestTime(ERequestResponseType requestType)
{
lastRequestTime[(int)requestType] = DateTime.Now;
}
Expand All @@ -102,7 +107,7 @@ public void SetLastRequestTime(ERequestType requestType)
/// Lock
/// </summary>
/// <param name="requestType">Request type</param>
public void Lock(ERequestType requestType)
public void Lock(ERequestResponseType requestType)
{
available[(int)requestType] = false;
values[(int)requestType] = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ namespace SAMPLauncherNET
/// <summary>
/// Backend restful API server class
/// </summary>
public class BackendRESTfulServer : Server
public class SAMPAPIServer : Server
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="serverData">Server data</param>
public BackendRESTfulServer(BackendRESTfulServerDataContract serverData) : base(serverData.Host, false)
public SAMPAPIServer(SAMPAPIServerDataContract serverData) : base(serverData.Host, false)
{
requestsRequired.Lock(ERequestType.Information);
requestsRequired.Lock(ERequestResponseType.Information);
if (serverData.Hostname.Trim().Length > 0)
{
hostname = serverData.Hostname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
namespace SAMPLauncherNET
{
/// <summary>
/// Server data contract class
/// SA:MP API server data contract class
/// </summary>
[DataContract]
public class BackendRESTfulServerDataContract
public class SAMPAPIServerDataContract
{
/// <summary>
/// Host
Expand Down
Loading

0 comments on commit a98b982

Please sign in to comment.