Initialize transport in network manager (#48)

This commit is contained in:
Paul Pacheco 2018-09-28 08:19:37 -05:00 committed by vis2k
parent 1e61aaa05a
commit 38a4ca27f4
3 changed files with 13 additions and 2 deletions

View File

@ -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()
@ -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.

View File

@ -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 //////////////////////////////////////////

View File

@ -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]);