Interface INetworkHandler
A handler that configures the network as a session start and stops.
Namespace: Unity.Services.Multiplayer
Syntax
public interface INetworkHandler
Remarks
Implement this interface and specify it using WithNetworkHandler<T>(T, INetworkHandler) to use sessions with a custom netcode solution, or to disable the default integration provided for Netcode for GameObjects and Netcode for Entities.
Methods
StartAsync(NetworkConfiguration)
Configure and start networking as a server, host, or client.
Declaration
Task StartAsync(NetworkConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
NetworkConfiguration | configuration | The network configuration to be used. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
Remarks
Use Role to determine the role along with all networking details. After the returned task completes, the game should be either listening and accepting connections (host or server) or connected (client).
For direct networking, the handler is allowed to modify the publish port UpdatePublishPort(UInt16) to handle the case of port 0.
StopAsync()
Stop networking.
Declaration
Task StopAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
Remarks
Use the Role obtained in StartAsync(NetworkConfiguration) to determine the role along with all networking details. After the returned task completes, the game should no longer be connected or accepting connections.