Skip to content

Commit

Permalink
feat: telepathy can now receive port from uri (#1284)
Browse files Browse the repository at this point in the history
* feat: telepathy can receive port from uri

* Use configured port if the url does not have one

* use tcp4 as scheme for telepathy

* don't change default port

* Update TelepathyTransport.cs

* Update TelepathyTransport.cs
  • Loading branch information
paulpach authored and miwarnec committed Dec 8, 2019
1 parent e766f7b commit 06946cf
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Assets/Mirror/Runtime/Transport/TelepathyTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace Mirror
[HelpURL("https://github.com/vis2k/Telepathy/blob/master/README.md")]
public class TelepathyTransport : Transport
{
// scheme used by this transport
public const string Scheme = "tcp4";

public ushort port = 7777;

[Tooltip("Nagle Algorithm can be disabled by enabling NoDelay")]
Expand Down Expand Up @@ -57,6 +60,14 @@ public override bool Available()
// client
public override bool ClientConnected() => client.Connected;
public override void ClientConnect(string address) => client.Connect(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;
client.Connect(uri.Host, serverPort);
}
public override bool ClientSend(int channelId, ArraySegment<byte> segment)
{
// telepathy doesn't support allocation-free sends yet.
Expand Down

0 comments on commit 06946cf

Please sign in to comment.