Version: 2017.2

NetworkServer

class in UnityEngine.Networking

Cambiar al Manual

Descripción

The NetworkServer uses a NetworkServerSimple for basic network functionality and adds more game-like functionality.

NetworkServer handles remote connections from remote clients via a NetworkServerSimple instance, and also has a local connection for a local client.

The NetworkServer is a singleton. It has static convenience functions such as NetworkServer.SendToAll() and NetworkServer.Spawn() which automatically use the singleton instance.

The NetworkManager uses the NetworkServer, but it can be used without the NetworkManager.

The set of networked objects that have been spawned is managed by NetworkServer. Objects are spawned with NetworkServer.Spawn() which adds them to this set, and makes them be created on clients. Spawned objects are removed automatically when they are destroyed, or than they can be removed from the spawned set by calling NetworkServer.UnSpawn() - this does not destroy the object.

There are a number of internal messages used by NetworkServer, these are setup when NetworkServer.Listen() is called.

Variables Estáticas

activeRevisa si el servidor se ha iniciado.
connectionsUna lista de todas las conexiones actuales de los clientes.
dontListenSi usted habilitad esto, el servidor no escuchará por conexiones entrantes en el puerto de red regular.
handlersDiccionario de los manejadores de mensajes registrados en el servidor.
hostTopologyLa topología anfitrión que el servidor está utilizando.
listenPortEl puerto en el que el servidor está escuchando.
localClientActiveTrue si el cliente local está actualmente activo en el servidor.
localConnectionsUna lista de las conexiones locales en el servidor.
maxDelayTiempo máximo de demora entre cada envío de paquetes en una conexión.
networkConnectionClassLa clase en utilizar cuando se cree conexiones en red nuevas.
numChannelsLa cantidad de canales con lo cual la red está configurada.
objectsEste es un diccionario los objetos en red que han sido generados en el servidor.
serverHostIdEl hostID transport layer utilizado por este servidor.
useWebSocketsEsto hace que el servidor escuche por conexiones a WebSockets en vez de conexiones normales del transport layer.

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.