Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

NetworkServer

class in UnityEngine.Networking

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual

Descripción

High level network server.

This class handles listening on a port and managing connections for clients that connect. It also handles game-related features such as player management, observers, spawning and message handling.

Variables Estáticas

activeChecks if the server has been started.
connectionsA list of all the current connections from clients.
dontListenIf you enable this, the server will not listen for incoming connections on the regular network port.
handlersDictionary of the message handlers registered with the server.
hostTopologyThe host topology that the server is using.
listenPortThe port that the server is listening on.
localClientActiveTrue is a local client is currently active on the server.
localConnectionsA list of local connections on the server.
maxDelayTiempo máximo de demora entre cada envío de paquetes en una conexión.
networkConnectionClassThe class to be used when creating new network connections.
numChannelsThe number of channels the network is configure with.
objectsThis is a dictionary of networked objects that have been spawned on the server.
serverHostIdThe transport layer hostId used by this server.
useWebSocketsThis makes the server listen for WebSockets connections instead of normal transport layer connections.

Funciones Estáticas

AddExternalConnectionThis accepts a network connection from another external source and adds it to the server.
AddPlayerForConnectionWhen an AddPlayer message handler has received a request from a player, the server calls this to associate the player object with the connection.
BecomeHostThis allows a client that has been disconnected from a server, to become the host of a new version of the game.
ClearHandlersClear all registered callback handlers.
ClearLocalObjectsThis clears all of the networked objects that the server is aware of. This can be required if a scene change deleted all of the objects without destroying them in the normal manner.
ClearSpawnersClears all registered spawn prefab and spawn handler functions for this server.
ConfigureThis configures the transport layer settings for the server.
DestroyDestroys this object and corresponding objects on all clients.
DestroyPlayersForConnectionThis destroys all the player objects associated with a NetworkConnections on a server.
DisconnectAllDisconnect all currently connected clients.
FindLocalObjectThis finds the local NetworkIdentity object with the specified network Id.
GetConnectionStatsGets aggregate packet stats for all connections.
GetStatsInGet inbound network statistics for the server.
GetStatsOutGet outbound network statistics for the client.
ListenStart the server on the given port number. Note that if a match has been created, this will listen using the relay server instead of a local socket.
ListenRelayStarts a server using a relay server. This is the manual way of using the relay server, as the regular NetworkServer.Connect() will automatically use the relay server if a match exists.
RegisterHandlerRegister a handler for a particular message type.
RemoveExternalConnectionThis removes an external connection added with AddExternalConnection().
ReplacePlayerForConnectionThis replaces the player object for a connection with a different player object. The old player object is not destroyed.
ResetReset the NetworkServer singleton.
ResetConnectionStatsResets the packet stats on all connections.
SendByChannelToAllSends a network message to all connected clients on a specified transport layer QoS channel.
SendByChannelToReadySends a network message to all connected clients that are "ready" on a specified transport layer QoS channel.
SendBytesToPlayerThis sends an array of bytes to a specific player.
SendBytesToReadyThis sends an array of bytes to all ready players.
SendToAllSend a message structure with the given type number to all connected clients.
SendToClientSend a message to the client which owns the given connection ID.
SendToClientOfPlayerSend a message to the client which owns the given player object instance.
SendToReadySend a message structure with the given type number to only clients which are ready.
SendUnreliableToAllSend given message structure as an unreliable message to all connected clients.
SendUnreliableToReadySend given message structure as an unreliable message only to ready clients.
SendWriterToReadySends the contents of a NetworkWriter object to the ready players.
SetAllClientsNotReadyMarks all connected clients as no longer ready.
SetClientNotReadySets the client of the connection to be not-ready.
SetClientReadySets the client to be ready.
SetNetworkConnectionClassThis sets the class used when creating new network connections.
ShutdownThis shuts down the server and disconnects all clients.
SpawnSpawn the given game object on all clients which are ready.
SpawnObjectsThis causes NetworkIdentity objects in a scene to be spawned on a server.
SpawnWithClientAuthorityThis spawns an object like NetworkServer.Spawn() but also assigns Client Authority to the specified client.
UnregisterHandlerUnregisters a handler for a particular message type.
UnSpawnThis takes an object that has been spawned and un-spawns it.