Class HostMigration
Host migration class used to access the host migration system, like getting the host migration data blob and functions for reacting to host migration events.
Inherited Members
Namespace: Unity.NetCode
Assembly: Unity.NetCode.dll
Syntax
public static class HostMigration
Methods
ConfigureClientAndConnect(World, INetworkStreamDriverConstructor, NetworkEndpoint)
Configure the client driver with the given driver constructor and connect to the endpoint. The NetworkDriverStore will be recreated as the client can be switching from a local IPC connection to relay connection or reversed, the relay data can be set at driver creation time.
Declaration
public static bool ConfigureClientAndConnect(World clientWorld, INetworkStreamDriverConstructor driverConstructor, NetworkEndpoint serverEndpoint)
Parameters
Type | Name | Description |
---|---|---|
World | clientWorld | The client world which needs to be configured. |
INetwork |
driverConstructor | The network driver constructor used for creating a new network driver in the client world. |
Network |
serverEndpoint | The network endpoint the client will connect to after configuring the network driver. |
Returns
Type | Description |
---|---|
bool | Returns true if the connect call succeeds |
GetHostMigrationData(World, ref NativeList<byte>)
Get the host migration data which has been collected by the host migration system. There is no limit enforced on the total size of the migration data.
Declaration
public static void GetHostMigrationData(World world, ref NativeList<byte> data)
Parameters
Type | Name | Description |
---|---|---|
World | world | The world where the migration data is stored |
Native |
data | Destination list to copy the data, this will be resized if it is too small to store all the data |
MigrateDataToNewServerWorld(INetworkStreamDriverConstructor, ref NativeArray<byte>)
Optional helper method to assist with the operations needed during a host migration process. Set
Takes the given host migration data and starts the host migration process. This starts loading
the entity scenes the host previously had loaded (if any). The Network
Declaration
public static bool MigrateDataToNewServerWorld(INetworkStreamDriverConstructor driverConstructor, ref NativeArray<byte> migrationData)
Parameters
Type | Name | Description |
---|---|---|
INetwork |
driverConstructor | The network driver constructor registered in the new server world and also in the client world. |
Native |
migrationData | The data blob containing host migration data, deployed to the new server world. |
Returns
Type | Description |
---|---|
bool | Returns false if there was any immediate failure when starting up the new server |
SetHostMigrationData(World, ref NativeArray<byte>)
Deploy the given host migration data in the given world. The data needs to be collected
by Get
Declaration
public static void SetHostMigrationData(World world, ref NativeArray<byte> migrationData)
Parameters
Type | Name | Description |
---|---|---|
World | world | Destination world to deploy the migration data |
Native |
migrationData | Host migration data collected by the host migration system |
TryGetHostMigrationData(World, ref NativeArray<byte>, out int)
Get the host migration data which has been collected by the host migration system. There is no limit enforced on the total size of the migration data.
Declaration
public static bool TryGetHostMigrationData(World world, ref NativeArray<byte> data, out int size)
Parameters
Type | Name | Description |
---|---|---|
World | world | The world where the migration data is stored |
Native |
data | Destination buffer to copy the data into |
int | size | The required size of the host data, this can be used to resize the destination buffer if it is too small |
Returns
Type | Description |
---|---|
bool | True if the data was successfully copied |