Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Jun 29, 2021
1 parent 0ce6c8d commit 833f853
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Net;

namespace OpenGSQ.Protocols
namespace OpenGSQ
{
public abstract class ProtocolBase
{
Expand Down
22 changes: 11 additions & 11 deletions OpenGSQ/Protocols/GameSpy2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,35 @@ public GameSpy2(string address, int port, int timeout = 5000) : base(address, po
/// <param name="request"></param>
/// <returns></returns>
/// <exception cref="SocketException"></exception>
public Response GetResponse(Request request = Request.Info | Request.Players | Request.Teams)
public Status GetStatus(Request request = Request.Info | Request.Players | Request.Teams)
{
using (var udpClient = new UdpClient())
{
var responseData = ConnectAndSend(udpClient, request);

using (var br = new BinaryReader(new MemoryStream(responseData), Encoding.UTF8))
{
var response = new Response();
var status = new Status();

// Save Response Info
if (request.HasFlag(Request.Info))
{
response.Info = GetInfo(br);
status.Info = GetInfo(br);
}

// Save Response Players
if (request.HasFlag(Request.Players))
{
response.Players = GetPlayers(br);
status.Players = GetPlayers(br);
}

// Save Response Teams
if (request.HasFlag(Request.Teams))
{
response.Teams = GetTeams(br);
status.Teams = GetTeams(br);
}

return response;
return status;
}
}
}
Expand Down Expand Up @@ -175,22 +175,22 @@ public enum Request : short
}

/// <summary>
/// Response object
/// Status object
/// </summary>
public class Response
public class Status
{
/// <summary>
/// Response Info
/// Status Info
/// </summary>
public Dictionary<string, string> Info { get; set; }

/// <summary>
/// Response Players
/// Status Players
/// </summary>
public List<Dictionary<string, string>> Players { get; set; }

/// <summary>
/// Response Teams
/// Status Teams
/// </summary>
public List<Dictionary<string, string>> Teams { get; set; }
}
Expand Down
20 changes: 10 additions & 10 deletions OpenGSQ/Protocols/GameSpy3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ public GameSpy3(string address, int port, int timeout = 5000) : base(address, po
/// </summary>
/// <returns></returns>
/// <exception cref="SocketException"></exception>
public Response GetResponse()
public Status GetStatus()
{
using (var udpClient = new UdpClient())
{
var responseData = ConnectAndSendPackets(udpClient);

using (var br = new BinaryReader(new MemoryStream(responseData), Encoding.UTF8))
{
return new Response
return new Status
{
// Save Response Info
// Save Status Info
Info = GetInfo(br),

// Save Response Players
// Save Status Players
Players = GetPlayers(br),

// Save Response Teams
// Save Status Teams
Teams = GetTeams(br)
};
}
Expand Down Expand Up @@ -307,22 +307,22 @@ private List<Dictionary<string, string>> GetTeams(BinaryReader br)
}

/// <summary>
/// Response object
/// Status object
/// </summary>
public class Response
public class Status
{
/// <summary>
/// Response Info
/// Status Info
/// </summary>
public Dictionary<string, string> Info { get; set; }

/// <summary>
/// Response Players
/// Status Players
/// </summary>
public List<Dictionary<string, string>> Players { get; set; }

/// <summary>
/// Response Teams
/// Status Teams
/// </summary>
public List<Dictionary<string, string>> Teams { get; set; }
}
Expand Down
4 changes: 2 additions & 2 deletions OpenGSQTests/Protocols/GameSpy2Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class GameSpy2Tests
[TestMethod()]
public void GetResponseTest()
{
var response = gameSpy2.GetResponse();
var response = gameSpy2.GetStatus();

Console.WriteLine(JsonSerializer.Serialize(response, typeof(GameSpy2.Response), options));
Console.WriteLine(JsonSerializer.Serialize(response, typeof(GameSpy2.Status), options));
}
}
}
4 changes: 2 additions & 2 deletions OpenGSQTests/Protocols/GameSpy3Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class GameSpy3Tests
[TestMethod()]
public void GetResponseTest()
{
var response = gameSpy3.GetResponse();
var response = gameSpy3.GetStatus();

Console.WriteLine(JsonSerializer.Serialize(response, typeof(GameSpy3.Response), options));
Console.WriteLine(JsonSerializer.Serialize(response, typeof(GameSpy3.Status), options));
}
}
}
4 changes: 2 additions & 2 deletions OpenGSQTests/Protocols/GameSpy4Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class GameSpy4Tests
[TestMethod()]
public void GetResponseTest()
{
var response = gameSpy4.GetResponse();
var response = gameSpy4.GetStatus();

Console.WriteLine(JsonSerializer.Serialize(response, typeof(GameSpy3.Response), options));
Console.WriteLine(JsonSerializer.Serialize(response, typeof(GameSpy3.Status), options));
}
}
}

0 comments on commit 833f853

Please sign in to comment.