Skip to content

Commit

Permalink
Initialize transport in network manager (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpach authored and miwarnec committed Sep 28, 2018
1 parent 1e61aaa commit 38a4ca2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Mirror/Runtime/NetworkManager.cs
Expand Up @@ -96,6 +96,7 @@ void Awake()
{
Debug.Log("Thank you for using Mirror! https://forum.unity.com/threads/unet-hlapi-community-edition.425437/");
InitializeSingleton();
InitializeTransport();
}

void InitializeSingleton()
Expand Down Expand Up @@ -140,6 +141,13 @@ void InitializeSingleton()
}
}

// Initializes the transport, by default it is Telepathy
// override method if you want to use a different transport
public virtual void InitializeTransport()
{
Transport.layer = new TelepathyWebsocketsMultiplexTransport();
}

// NetworkIdentity.UNetStaticUpdate is called from UnityEngine while LLAPI network is active.
// if we want TCP then we need to call it manually. probably best from NetworkManager, although this means
// that we can't use NetworkServer/NetworkClient without a NetworkManager invoking Update anymore.
Expand Down
6 changes: 4 additions & 2 deletions Mirror/Runtime/Transport/Transport.cs
Expand Up @@ -9,8 +9,10 @@ public static class Transport
// hlapi needs to know max packet size to show warnings
public static int MaxPacketSize = ushort.MaxValue;

// selected transport layer: Telepathy by default
public static TransportLayer layer = new TelepathyWebsocketsMultiplexTransport();
// selected transport layer
// the transport is normally initialized in NetworkManager InitializeTransport
// initialize it yourself if you are not using NetworkManager
public static TransportLayer layer;
}

// abstract transport layer class //////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions Mirror/Tests/NetworkWriterTest.cs
Expand Up @@ -31,6 +31,7 @@ public void TestWritingLargeMessage()
[Test]
public void TestWritingHugeArray()
{
Transport.MaxPacketSize = 1000000;
// try serializing array > 64KB and see what happens
NetworkWriter writer = new NetworkWriter();
writer.WriteBytesAndSize(new byte[100000]);
Expand Down

0 comments on commit 38a4ca2

Please sign in to comment.