Skip to content

Commit

Permalink
feat: LLAPI transport can receive port from uri (#1294)
Browse files Browse the repository at this point in the history
* feat: LLAPI transport can receive port from uri

* Refactor to use the original method
  • Loading branch information
paulpach authored and miwarnec committed Dec 9, 2019
1 parent c8ad118 commit 7865a84
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Assets/Mirror/Runtime/Transport/LLAPITransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Mirror
[EditorBrowsable(EditorBrowsableState.Never), Obsolete("LLAPI is obsolete and will be removed from future versions of Unity")]
public class LLAPITransport : Transport
{
public const string Scheme = "unet";

public ushort port = 7777;

[Tooltip("Enable for WebGL games. Can only do either WebSockets or regular Sockets, not both (yet).")]
Expand Down Expand Up @@ -110,7 +112,9 @@ public override bool ClientConnected()
return clientConnectionId != -1;
}

public override void ClientConnect(string address)


void ClientConnect(string address, int port)
{
// LLAPI can't handle 'localhost'
if (address.ToLower() == "localhost") address = "127.0.0.1";
Expand All @@ -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)
{
// Send buffer is copied internally, so we can get rid of segment
Expand Down

0 comments on commit 7865a84

Please sign in to comment.