Skip to content

Commit

Permalink
feat: Multiplex based on url (#1295)
Browse files Browse the repository at this point in the history
If the multiplex transport receives an url for connection,
try all the underlying transports until it finds a suitable one

For example,  let's say you configure a multiplex transport with telepathy and websocket,  if you try:
```cs
NetworkManager.StartClient("tcp4://host:port");
```

then the multiplex transport will use telepathy.

if we pass:
```cs
NetworkManager.StartClient("ws://host:port");
```

then the multiplex transport will select websocket
  • Loading branch information
paulpach authored and miwarnec committed Dec 10, 2019
1 parent c2d8cdf commit c206f9a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Assets/Mirror/Runtime/Transport/MultiplexTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@ public override void ClientConnect(string address)
throw new Exception("No transport suitable for this platform");
}

public override void ClientConnect(Uri uri)
{
foreach (Transport transport in transports)
{
if (transport.Available())
{
try
{
transport.ClientConnect(uri);
available = transport;
}
catch (ArgumentException)
{
// transport does not support the schema, just move on to the next one
}
}
}
throw new Exception("No transport suitable for this platform");
}

public override bool ClientConnected()
{
return available != null && available.ClientConnected();
Expand Down

0 comments on commit c206f9a

Please sign in to comment.