Struct MultiNetworkDriver
The MultiNetworkDriver
structure is a way to manipulate multiple instances of
Network
Implements
Inherited Members
Namespace: Unity.Networking.Transport
Assembly: solution.dll
Syntax
public struct MultiNetworkDriver : IDisposable
Examples
This code below shows how to create a MultiNetworkDriver
that accepts both UDP and
WebSocket connections.
var udpDriver = NetworkDriver.Create(new UDPNetworkInterface());
udpDriver.Bind(NetworkEndpoint.AnyIpv4.WithPort(7777)); // UDP port
udpDriver.Listen();
var wsDriver = NetworkDriver.Create(new WebSocketNetworkInterface());
wsDriver.Bind(NetworkEndpoint.AnyIpv4.WithPort(7777)); // TCP port
wsDriver.Listen();
var multiDriver = MultiNetworkDriver.Create();
multiDriver.AddDriver(udpDriver);
multiDriver.AddDriver(wsDriver);
The created MultiNetworkDriver
can then be used as one would use a
Network
Fields
Name | Description |
---|---|
Max |
The maximum number of drivers that can be added to a |
Properties
Name | Description |
---|---|
Driver |
Number of drivers that have been added. |
Is |
Whether the |
Methods
Name | Description |
---|---|
Abort |
Aborts a send started with Begin |
Accept() | Accept any new incoming connections. Connections must be accepted before data can be
sent on them. It's also the only way to obtain the Network |
Add |
Add a Network |
Begin |
Begin sending data on the given connection (default pipeline). |
Begin |
Begin sending data on the given connection and pipeline. |
Connect(int, Network |
Establish a new connection to the given endpoint. Note that this only starts establishing the new connection. From there it will either succeeds (a Connect event will pop on the connection) or fail (a Disconnect event will pop on the connection) at a later time. |
Create() | Create a new |
Create |
Create a new pipeline from stage types. |
Create |
Create a new pipeline from stage types. |
Disconnect(Network |
Close a connection. Note that to properly notify a peer of this disconnection, it is
required to schedule at least one update with Schedule |
Dispose() | Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. |
End |
Enqueue a send operation for the data in the given Data |
Get |
Get the current state of the given connection. |
Get |
Get a Network |
Get |
Get the Network |
Get |
Get the remote endpoint of a connection (the endpoint used to reach the remote peer on the connection). |
Pop |
Pops the next event from the event queue, Empty will be returned if there are no more events to pop. |
Pop |
Pops the next event from the event queue, Empty will be returned if there are no more events to pop. |
Pop |
Pops the next event from the event queue for the given connection, Empty will be returned if there are no more events. |
Pop |
Pops the next event from the event queue for the given connection, Empty will be returned if there are no more events. |
Register |
Register a custom pipeline stage. |
Schedule |
Schedule a send job. This job is basically a subset of the update job (see
Schedule |
Schedule |
Schedule an update job. This job will process incoming packets and check timeouts
(queueing up the relevant events to be consumed by Pop |
To |
Create a Network |