C# Class UnityEngine.Networking.NetworkConnection

A High level network connection. This is used for connections from client-to-server and for connection from server-to-client.

Inheritance: IDisposable
Afficher le fichier Open project: CarlosHBC/UnityDecompiled Class Usage Examples

Méthodes publiques

Свойство Type Description
address string
connectionId int
hostId int
isReady bool
lastMessageTime float
logNetworkMessages bool

Private Properties

Свойство Type Description
AddOwnedObject void
AddToVisList void
CheckChannel bool
GetPlayerController bool
HandleFragment void
IsReliableQoS bool
IsSequencedQoS bool
LogSend void
OnFragment void
RemoveFromVisList void
RemoveObservers void
RemoveOwnedObject void
RemovePlayerController void
SetHandlers void
SetPlayerController void

Méthodes publiques

Méthode Description
CheckHandler ( short msgType ) : bool

This function checks if there is a message handler registered for the message ID.

Disconnect ( ) : void

Disconnects this connection.

Dispose ( ) : void

Disposes of this connection, releasing channel buffers that it holds.

FlushChannels ( ) : void

This causes the channels of the network connection to flush their data to the transport layer.

GetStatsIn ( int &numMsgs, int &numBytes ) : void
GetStatsOut ( int &numMsgs, int &numBufferedMsgs, int &numBytes, int &lastBufferedPerSecond ) : void
Initialize ( string networkAddress, int networkHostId, int networkConnectionId, HostTopology hostTopology ) : void

This inializes the internal data structures of a NetworkConnection object, including channel buffers.

InvokeHandler ( NetworkMessage netMsg ) : bool

This function invokes the registered handler function for a message.

InvokeHandler ( short msgType, NetworkReader reader, int channelId ) : bool

This function invokes the registered handler function for a message.

InvokeHandlerNoData ( short msgType ) : bool

This function invokes the registered handler function for a message, without any message data.

RegisterHandler ( short msgType, NetworkMessageDelegate handler ) : void

This registers a handler function for a message Id.

ResetStats ( ) : void

Resets the statistics that are returned from NetworkClient.GetConnectionStats().

Send ( short msgType, MessageBase msg ) : bool

This sends a network message with a message ID on the connection. This message is sent on channel zero, which by default is the reliable channel.

SendByChannel ( short msgType, MessageBase msg, int channelId ) : bool

This sends a network message on the connection using a specific transport layer channel.

SendBytes ( byte bytes, int numBytes, int channelId ) : bool

This sends an array of bytes on the connection.

SendUnreliable ( short msgType, MessageBase msg ) : bool

This sends a network message with a message ID on the connection. This message is sent on channel one, which by default is the unreliable channel.

SendWriter ( NetworkWriter writer, int channelId ) : bool

This sends the contents of a NetworkWriter object on the connection.

SetChannelOption ( int channelId, ChannelOption option, int value ) : bool

This sets an option on the network channel.

SetMaxDelay ( float seconds ) : void

The maximum time in seconds that messages are buffered before being sent.

ToString ( ) : string

Returns a string representation of the NetworkConnection object state.

TransportRecieve ( byte bytes, int numBytes, int channelId ) : void

This virtual function allows custom network connection classes to process data from the network before it is passed to the application.

TransportSend ( byte bytes, int numBytes, int channelId, byte &error ) : bool
UnregisterHandler ( short msgType ) : void

This removes the handler registered for a message Id.

Méthodes protégées

Méthode Description
Dispose ( bool disposing ) : void
HandleBytes ( byte buffer, int receivedSize, int channelId ) : void

This makes the connection process the data contained in the buffer, and call handler functions.

HandleReader ( NetworkReader reader, int receivedSize, int channelId ) : void

This makes the connection process the data contained in the stream, and call handler functions.

Private Methods

Méthode Description
AddOwnedObject ( NetworkIdentity obj ) : void
AddToVisList ( NetworkIdentity uv ) : void
CheckChannel ( int channelId ) : bool
GetPlayerController ( short playerControllerId, PlayerController &playerController ) : bool
HandleFragment ( NetworkReader reader, int channelId ) : void
IsReliableQoS ( QosType qos ) : bool
IsSequencedQoS ( QosType qos ) : bool
LogSend ( byte bytes ) : void
OnFragment ( NetworkMessage netMsg ) : void
RemoveFromVisList ( NetworkIdentity uv, bool isDestroyed ) : void
RemoveObservers ( ) : void
RemoveOwnedObject ( NetworkIdentity obj ) : void
RemovePlayerController ( short playerControllerId ) : void
SetHandlers ( NetworkMessageHandlers handlers ) : void
SetPlayerController ( PlayerController player ) : void

Method Details

CheckHandler() public méthode

This function checks if there is a message handler registered for the message ID.

public CheckHandler ( short msgType ) : bool
msgType short The message ID of the handler to look for.
Résultat bool

Disconnect() public méthode

Disconnects this connection.

public Disconnect ( ) : void
Résultat void

Dispose() public méthode

Disposes of this connection, releasing channel buffers that it holds.

public Dispose ( ) : void
Résultat void

Dispose() protected méthode

protected Dispose ( bool disposing ) : void
disposing bool
Résultat void

FlushChannels() public méthode

This causes the channels of the network connection to flush their data to the transport layer.

public FlushChannels ( ) : void
Résultat void

GetStatsIn() public méthode

public GetStatsIn ( int &numMsgs, int &numBytes ) : void
numMsgs int
numBytes int
Résultat void

GetStatsOut() public méthode

public GetStatsOut ( int &numMsgs, int &numBufferedMsgs, int &numBytes, int &lastBufferedPerSecond ) : void
numMsgs int
numBufferedMsgs int
numBytes int
lastBufferedPerSecond int
Résultat void

HandleBytes() protected méthode

This makes the connection process the data contained in the buffer, and call handler functions.

protected HandleBytes ( byte buffer, int receivedSize, int channelId ) : void
buffer byte Data to process.
receivedSize int Size of the data to process.
channelId int Channel the data was recieved on.
Résultat void

HandleReader() protected méthode

This makes the connection process the data contained in the stream, and call handler functions.

protected HandleReader ( NetworkReader reader, int receivedSize, int channelId ) : void
reader NetworkReader Stream that contains data.
receivedSize int Size of the data.
channelId int Channel the data was received on.
Résultat void

Initialize() public méthode

This inializes the internal data structures of a NetworkConnection object, including channel buffers.

public Initialize ( string networkAddress, int networkHostId, int networkConnectionId, HostTopology hostTopology ) : void
networkAddress string The host or IP connected to.
networkHostId int The transport hostId for the connection.
networkConnectionId int The transport connectionId for the connection.
hostTopology HostTopology The topology to be used.
Résultat void

InvokeHandler() public méthode

This function invokes the registered handler function for a message.

public InvokeHandler ( NetworkMessage netMsg ) : bool
netMsg NetworkMessage The message object to process.
Résultat bool

InvokeHandler() public méthode

This function invokes the registered handler function for a message.

public InvokeHandler ( short msgType, NetworkReader reader, int channelId ) : bool
msgType short The message type of the handler to use.
reader NetworkReader The stream to read the contents of the message from.
channelId int The channel that the message arrived on.
Résultat bool

InvokeHandlerNoData() public méthode

This function invokes the registered handler function for a message, without any message data.

public InvokeHandlerNoData ( short msgType ) : bool
msgType short The message ID of the handler to invoke.
Résultat bool

RegisterHandler() public méthode

This registers a handler function for a message Id.

public RegisterHandler ( short msgType, NetworkMessageDelegate handler ) : void
msgType short The message ID to register.
handler NetworkMessageDelegate The handler function to register.
Résultat void

ResetStats() public méthode

Resets the statistics that are returned from NetworkClient.GetConnectionStats().

public ResetStats ( ) : void
Résultat void

Send() public méthode

This sends a network message with a message ID on the connection. This message is sent on channel zero, which by default is the reliable channel.

public Send ( short msgType, MessageBase msg ) : bool
msgType short The ID of the message to send.
msg MessageBase The message to send.
Résultat bool

SendByChannel() public méthode

This sends a network message on the connection using a specific transport layer channel.

public SendByChannel ( short msgType, MessageBase msg, int channelId ) : bool
msgType short The message ID to send.
msg MessageBase The message to send.
channelId int The transport layer channel to send on.
Résultat bool

SendBytes() public méthode

This sends an array of bytes on the connection.

public SendBytes ( byte bytes, int numBytes, int channelId ) : bool
bytes byte The array of data to be sent.
numBytes int The number of bytes in the array to be sent.
channelId int The transport channel to send on.
Résultat bool

SendUnreliable() public méthode

This sends a network message with a message ID on the connection. This message is sent on channel one, which by default is the unreliable channel.

public SendUnreliable ( short msgType, MessageBase msg ) : bool
msgType short The message ID to send.
msg MessageBase The message to send.
Résultat bool

SendWriter() public méthode

This sends the contents of a NetworkWriter object on the connection.

public SendWriter ( NetworkWriter writer, int channelId ) : bool
writer NetworkWriter A writer object containing data to send.
channelId int The transport channel to send on.
Résultat bool

SetChannelOption() public méthode

This sets an option on the network channel.

public SetChannelOption ( int channelId, ChannelOption option, int value ) : bool
channelId int The channel the option will be set on.
option ChannelOption The option to set.
value int The value for the option.
Résultat bool

SetMaxDelay() public méthode

The maximum time in seconds that messages are buffered before being sent.

public SetMaxDelay ( float seconds ) : void
seconds float Time in seconds.
Résultat void

ToString() public méthode

Returns a string representation of the NetworkConnection object state.

public ToString ( ) : string
Résultat string

TransportRecieve() public méthode

This virtual function allows custom network connection classes to process data from the network before it is passed to the application.

public TransportRecieve ( byte bytes, int numBytes, int channelId ) : void
bytes byte The data recieved.
numBytes int The size of the data recieved.
channelId int The channel that the data was received on.
Résultat void

TransportSend() public méthode

public TransportSend ( byte bytes, int numBytes, int channelId, byte &error ) : bool
bytes byte
numBytes int
channelId int
error byte
Résultat bool

UnregisterHandler() public méthode

This removes the handler registered for a message Id.

public UnregisterHandler ( short msgType ) : void
msgType short The message ID to unregister.
Résultat void

Property Details

address public_oe property

The IP address associated with the connection.

public string address
Résultat string

connectionId public_oe property

Unique identifier for this connection that is assigned by the transport layer.

public int connectionId
Résultat int

hostId public_oe property

Transport level host ID for this connection.

public int hostId
Résultat int

isReady public_oe property

Flag that tells if the connection has been marked as "ready" by a client calling ClientScene.Ready().

public bool isReady
Résultat bool

lastMessageTime public_oe property

The last time that a message was received on this connection.

public float lastMessageTime
Résultat float

logNetworkMessages public_oe property

Setting this to true will log the contents of network message to the console.

public bool logNetworkMessages
Résultat bool