NetworkServer使用NetworkServerSimple实现基本的网络功能,并添加更多类似游戏的功能。密封类。
属性
public static Type networkConnectionClass { get; }
摘要:创建新网络连接时要使用的类。
public static List<NetworkConnection> localConnections { get; }
摘要:服务器上本地连接的列表。
public static ReadOnlyCollection<NetworkConnection> connections { get; }
摘要:来自客户端的所有当前连接的列表。
public static Dictionary<short, NetworkMessageDelegate> handlers { get; }
摘要:在服务器上注册的消息处理程序的字典。
public static HostTopology hostTopology { get; }
摘要: 服务器正在使用的主机拓扑。
public static Dictionary<NetworkInstanceId, NetworkIdentity> objects { get; }
摘要: 这是在服务器上生成的网络对象字典。
public static bool sendPeerInfo { get; set; }
摘要: 设置为true将使服务器向网络的所有参与者发送对等信息。
public static bool dontListen { get; set; }
摘要: 如果启用此选项,服务器将不会侦听常规网络端口上的传入连接。
public static bool useWebSockets { get; set; }
摘要:这使得服务器监听WebSockets连接,而不是普通的传输层连接。
public static bool active { get; }
摘要:检查服务器是否已启动。
public static float maxDelay { get; set; }
摘要:在连接上发送分组之前的最大延迟。
public static int listenPort { get; }
摘要:服务器正在侦听的端口。
public static bool localClientActive { get; }
摘要:True表示服务器上当前处于活动状态的本地客户端。
public static int serverHostId { get; }
摘要:此服务器使用的传输层主机ID。
public static int numChannels { get; }
摘要:网络配置的通道数。
方法
public static bool AddExternalConnection(NetworkConnection conn);
public static bool AddPlayerForConnection(NetworkConnection conn, GameObject player, short playerControllerId, NetworkHash128 assetId);
public static bool AddPlayerForConnection(NetworkConnection conn, GameObject player, short playerControllerId);
public static bool AddPlayerForConnection(NetworkConnection conn, GameObject player, short playerControllerId);
public static void ClearHandlers();
public static void ClearLocalObjects();
public static void ClearSpawners();
public static bool Configure(HostTopology topology);
public static bool Configure(ConnectionConfig config, int maxConnections);
public static void Destroy(GameObject obj);
public static void DestroyPlayersForConnection(NetworkConnection conn);
public static void DisconnectAll();
public static GameObject FindLocalObject(NetworkInstanceId netId);
public static Dictionary<short, NetworkConnection.PacketStat> GetConnectionStats();
public static void GetStatsIn(out int numMsgs, out int numBytes);
public static void GetStatsOut(out int numMsgs, out int numBufferedMsgs, out int numBytes, out int lastBufferedPerSecond);
public static bool Listen(MatchInfo matchInfo, int listenPort);
public static bool Listen(int serverPort);
public static bool Listen(string ipAddress, int serverPort);
public static void ListenRelay(string relayIp, int relayPort, NetworkID netGuid, SourceID sourceId, NodeID nodeId);
public static void RegisterHandler(short msgType, NetworkMessageDelegate handler);
public static void RemoveExternalConnection(int connectionId);
public static bool ReplacePlayerForConnection(NetworkConnection conn, GameObject player, short playerControllerId, NetworkHash128 assetId);
public static bool ReplacePlayerForConnection(NetworkConnection conn, GameObject player, short playerControllerId);
public static void Reset();
public static void ResetConnectionStats();
public static bool SendByChannelToAll(short msgType, MessageBase msg, int channelId);
public static bool SendByChannelToReady(GameObject contextObj, short msgType, MessageBase msg, int channelId);
public static void SendBytesToPlayer(GameObject player, byte[] buffer, int numBytes, int channelId);
public static void SendBytesToReady(GameObject contextObj, byte[] buffer, int numBytes, int channelId);
public static bool SendToAll(short msgType, MessageBase msg);
public static void SendToClient(int connectionId, short msgType, MessageBase msg);
public static void SendToClientOfPlayer(GameObject player, short msgType, MessageBase msg);
public static bool SendToReady(GameObject contextObj, short msgType, MessageBase msg);
public static bool SendUnreliableToAll(short msgType, MessageBase msg);
public static bool SendUnreliableToReady(GameObject contextObj, short msgType, MessageBase msg);
public static void SendWriterToReady(GameObject contextObj, NetworkWriter writer, int channelId);
public static void SetAllClientsNotReady();
public static void SetClientNotReady(NetworkConnection conn);
public static void SetClientReady(NetworkConnection conn);
public static void SetNetworkConnectionClass<T>() where T : NetworkConnection;
public static void Shutdown();
public static void Spawn(GameObject obj, NetworkHash128 assetId);
public static void Spawn(GameObject obj);
public static bool SpawnObjects();
public static bool SpawnWithClientAuthority(GameObject obj, NetworkHash128 assetId, NetworkConnection conn);
public static bool SpawnWithClientAuthority(GameObject obj, NetworkConnection conn);
public static bool SpawnWithClientAuthority(GameObject obj, GameObject player);
public static void UnregisterHandler(short msgType);
public static void UnSpawn(GameObject obj);
public void SendNetworkInfo(NetworkConnection targetConnection);