Change `SocketServer.Port` to a u16 (y'know like ports are)

This commit is contained in:
YoshiRulz 2024-06-12 06:40:24 +10:00
parent b742998296
commit 044729cc57
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
4 changed files with 10 additions and 10 deletions

View File

@ -24,7 +24,7 @@ namespace BizHawk.Client.Common
private readonly Func<byte[]> _takeScreenshotCallback;
private (string HostIP, int Port) _targetAddr;
private (string HostIP, ushort Port) _targetAddr;
public bool Connected { get; private set; }
@ -38,7 +38,7 @@ namespace BizHawk.Client.Common
}
}
public int Port
public ushort Port
{
get => _targetAddr.Port;
set
@ -48,7 +48,7 @@ namespace BizHawk.Client.Common
}
}
public (string HostIP, int Port) TargetAddress
public (string HostIP, ushort Port) TargetAddress
{
get => _targetAddr;
set
@ -66,7 +66,7 @@ namespace BizHawk.Client.Common
public bool Successful { get; private set; }
public SocketServer(Func<byte[]> takeScreenshotCallback, ProtocolType protocol, string ip, int port)
public SocketServer(Func<byte[]> takeScreenshotCallback, ProtocolType protocol, string ip, ushort port)
{
_protocol = protocol;
ReinitSocket(out _soc);

View File

@ -37,7 +37,7 @@ namespace BizHawk.Client.Common
bool? startFullscreen = null;
string? luaScript = null;
bool? luaConsole = null;
int? socketPort = null;
ushort? socketPort = null;
string? socketIP = null;
string? mmfFilename = null;
string? urlGet = null;
@ -131,7 +131,7 @@ namespace BizHawk.Client.Common
}
else if (argDowncased.StartsWithOrdinal("--socket_port="))
{
var port = int.TryParse(argDowncased.Substring(argDowncased.IndexOf('=') + 1), out var i1) ? i1 : default;
var port = ushort.TryParse(arg.Substring(14), out var i1) ? i1 : (ushort) 0;
if (port > 0) socketPort = port;
}
else if (argDowncased.StartsWithOrdinal("--socket_ip="))
@ -184,7 +184,7 @@ namespace BizHawk.Client.Common
var httpAddresses = urlGet == null && urlPost == null
? ((string?, string?)?) null // don't bother
: (urlGet, urlPost);
(string, int)? socketAddress;
(string, ushort)? socketAddress;
if (socketIP == null && socketPort == null)
{
socketAddress = null; // don't bother

View File

@ -35,7 +35,7 @@ namespace BizHawk.Client.Common
public readonly bool luaConsole;
public readonly (string IP, int Port)? SocketAddress;
public readonly (string IP, ushort Port)? SocketAddress;
public readonly ProtocolType SocketProtocol;
@ -66,7 +66,7 @@ namespace BizHawk.Client.Common
bool startFullscreen,
string? luaScript,
bool luaConsole,
(string IP, int Port)? socketAddress,
(string IP, ushort Port)? socketAddress,
string? mmfFilename,
(string? UrlGet, string? UrlPost)? httpAddresses,
bool? audiosync,

View File

@ -93,7 +93,7 @@ namespace BizHawk.Client.Common
}
[LuaMethod("socketServerSetPort", "sets the port of the Lua socket server")]
public void SocketServerSetPort(int port)
public void SocketServerSetPort(ushort port)
{
CheckSocketServer();
APIs.Comm.Sockets.Port = port;