mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
feat: LLAPI transport can receive port from uri (#1294)
* feat: LLAPI transport can receive port from uri * Refactor to use the original method
This commit is contained in:
parent
c8ad118d50
commit
7865a840b6
@ -18,6 +18,8 @@ namespace Mirror
|
|||||||
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("LLAPI is obsolete and will be removed from future versions of Unity")]
|
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("LLAPI is obsolete and will be removed from future versions of Unity")]
|
||||||
public class LLAPITransport : Transport
|
public class LLAPITransport : Transport
|
||||||
{
|
{
|
||||||
|
public const string Scheme = "unet";
|
||||||
|
|
||||||
public ushort port = 7777;
|
public ushort port = 7777;
|
||||||
|
|
||||||
[Tooltip("Enable for WebGL games. Can only do either WebSockets or regular Sockets, not both (yet).")]
|
[Tooltip("Enable for WebGL games. Can only do either WebSockets or regular Sockets, not both (yet).")]
|
||||||
@ -110,7 +112,9 @@ public override bool ClientConnected()
|
|||||||
return clientConnectionId != -1;
|
return clientConnectionId != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ClientConnect(string address)
|
|
||||||
|
|
||||||
|
void ClientConnect(string address, int port)
|
||||||
{
|
{
|
||||||
// LLAPI can't handle 'localhost'
|
// LLAPI can't handle 'localhost'
|
||||||
if (address.ToLower() == "localhost") address = "127.0.0.1";
|
if (address.ToLower() == "localhost") address = "127.0.0.1";
|
||||||
@ -131,6 +135,21 @@ public override void ClientConnect(string address)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void ClientConnect(string address)
|
||||||
|
{
|
||||||
|
ClientConnect(address, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void ClientConnect(Uri uri)
|
||||||
|
{
|
||||||
|
if (uri.Scheme != Scheme)
|
||||||
|
throw new ArgumentException($"Invalid url {uri}, use {Scheme}://host:port instead", nameof(uri));
|
||||||
|
|
||||||
|
int serverPort = uri.IsDefaultPort ? port : uri.Port;
|
||||||
|
|
||||||
|
ClientConnect(uri.Host, serverPort);
|
||||||
|
}
|
||||||
|
|
||||||
public override bool ClientSend(int channelId, ArraySegment<byte> segment)
|
public override bool ClientSend(int channelId, ArraySegment<byte> segment)
|
||||||
{
|
{
|
||||||
// Send buffer is copied internally, so we can get rid of segment
|
// Send buffer is copied internally, so we can get rid of segment
|
||||||
|
Loading…
Reference in New Issue
Block a user