Struct NetworkConnection
Public representation of a connection. This is obtained by calling
Accept(out Native
Implements
Inherited Members
Namespace: Unity.Networking.Transport
Assembly: Unity.Networking.Transport.dll
Syntax
public struct NetworkConnection : IEquatable<NetworkConnection>
Properties
IsCreated
Whether the connection was correctly obtained from a call to
Accept(out Native
Declaration
public bool IsCreated { get; }
Property Value
Type | Description |
---|---|
bool | True if created correctly, false otherwise. |
Methods
Close(NetworkDriver)
Close an active connection. Strictly identical to Disconnect(Network
Declaration
public int Close(NetworkDriver driver)
Parameters
Type | Name | Description |
---|---|---|
Network |
driver | Driver on which to perform the operation. |
Returns
Type | Description |
---|---|
int | 0 on success, a negative error code otherwise. |
Disconnect(NetworkDriver)
Close an active connection. Strictly identical to Close(Network
Declaration
public int Disconnect(NetworkDriver driver)
Parameters
Type | Name | Description |
---|---|---|
Network |
driver | Driver on which to perform the operation. |
Returns
Type | Description |
---|---|
int | 0 on success, a negative error code otherwise. |
Equals(object)
Declaration
public override bool Equals(object o)
Parameters
Type | Name | Description |
---|---|---|
object | o |
Returns
Type | Description |
---|---|
bool |
Overrides
Equals(NetworkConnection)
Declaration
public bool Equals(NetworkConnection o)
Parameters
Type | Name | Description |
---|---|---|
Network |
o |
Returns
Type | Description |
---|---|
bool |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
GetState(NetworkDriver)
Get the current state of a connection.
Declaration
public NetworkConnection.State GetState(NetworkDriver driver)
Parameters
Type | Name | Description |
---|---|---|
Network |
driver | Driver to get the state from. |
Returns
Type | Description |
---|---|
Network |
Current state of the connection. |
PopEvent(NetworkDriver, out DataStreamReader)
Pop the next available event on the connection.
Declaration
public NetworkEvent.Type PopEvent(NetworkDriver driver, out DataStreamReader stream)
Parameters
Type | Name | Description |
---|---|---|
Network |
driver | Driver from which to get the event. |
Data |
stream | Reader into the data associated to the event. Only populated if the returned event is Data or Disconnect, where respectively the data will be either the received payload, or the disconnection reason (as a single byte). |
Returns
Type | Description |
---|---|
Network |
Type of the popped event. Empty if nothing to pop. |
PopEvent(NetworkDriver, out DataStreamReader, out NetworkPipeline)
Pop the next available event on the connection.
Declaration
public NetworkEvent.Type PopEvent(NetworkDriver driver, out DataStreamReader stream, out NetworkPipeline pipeline)
Parameters
Type | Name | Description |
---|---|---|
Network |
driver | Driver from which to get the event. |
Data |
stream | Reader into the data associated to the event. Only populated if the returned event is Data or Disconnect, where respectively the data will be either the received payload, or the disconnection reason (as a single byte). |
Network |
pipeline | Pipeline on which the data was received. |
Returns
Type | Description |
---|---|
Network |
Type of the popped event. Empty if nothing to pop. |
ToFixedString()
Return a fixed string representation of the connection. For use in contexts where
To
Declaration
public FixedString128Bytes ToFixedString()
Returns
Type | Description |
---|---|
Fixed |
Fixed string representation of the connection. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |
Overrides
Operators
operator ==(NetworkConnection, NetworkConnection)
Declaration
public static bool operator ==(NetworkConnection lhs, NetworkConnection rhs)
Parameters
Type | Name | Description |
---|---|---|
Network |
lhs | |
Network |
rhs |
Returns
Type | Description |
---|---|
bool |
operator !=(NetworkConnection, NetworkConnection)
Declaration
public static bool operator !=(NetworkConnection lhs, NetworkConnection rhs)
Parameters
Type | Name | Description |
---|---|---|
Network |
lhs | |
Network |
rhs |
Returns
Type | Description |
---|---|
bool |