NetworkClient

class in UnityEngine.Networking

매뉴얼로 전환

설명

This is a network client class used by the networking system. It contains a NetworkConnection that is used to connect to a network server.

The NetworkClient handle connection state, messages handlers, and connection configuration. There can be many NetworkClient instances in a process at a time, but only one that is connected to a game server (NetworkServer) that uses spawned objects.

NetworkClient has an internal update function where it handles events from the transport layer. This includes asynchronous connect events, disconnect events and incoming data from a server.

The NetworkManager has a NetworkClient instance that it uses for games that it starts, but the NetworkClient may be used by itself.

정적 변수

activeTrue if a network client is currently active.
allClientsA list of all the active network clients in the current process.

변수

connectionThe NetworkConnection object this client is using.
handlersThe registered network message handlers.
hostPortThe local port that the network client uses to connect to the server.
hostTopologyThe host topology that this client is using.
isConnectedThis gives the current connection status of the client.
networkConnectionClassThe class to use when creating new NetworkConnections.
numChannelsThe number of QoS channels currently configured for this client.
serverIpThe IP address of the server that this client is connected to.
serverPortThe port of the server that this client is connected to.

생성자

NetworkClientCreates a new NetworkClient instance.

Public 함수

ConfigureThis configures the transport layer settings for a client.
ConnectConnect client to a NetworkServer instance.
ConnectWithSimulatorConnect client to a NetworkServer instance with simulated latency and packet loss.
DisconnectDisconnect from server.
GetConnectionStatsRetrieves statistics about the network packets sent on this connection.
GetRTTGets the Return Trip Time for this connection.
GetStatsInGet inbound network statistics for the client.
GetStatsOutGet outbound network statistics for the client.
ReconnectToNewHostThis is used by a client that has lost the connection to the old host, to reconnect to the new host of a game.
RegisterHandlerRegister a handler for a particular message type.
ResetConnectionStatsResets the statistics return by NetworkClient.GetConnectionStats() to zero values.
SendThis sends a network message with a message Id to the server. This message is sent on channel zero, which by default is the reliable channel.
SendByChannelThis sends a network message with a message Id to the server on a specific channel.
SendBytesThis sends the data in an array of bytes to the server that the client is connected to.
SendUnreliableThis sends a network message with a message Id to the server on channel one, which by default is the unreliable channel.
SendWriterThis sends the contents of the NetworkWriter's buffer to the connected server on the specified channel.
SetMaxDelaySet the maximum amount of time that can pass for transmitting the send buffer.
SetNetworkConnectionClassThis sets the class that is used when creating new network connections.
ShutdownShut down a client.
UnregisterHandlerUnregisters a network message handler.

정적 함수

GetTotalConnectionStatsRetrieves statistics about the network packets sent on all connections.
ShutdownAllShuts down all network clients.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961