Network.OnDisconnectedFromServer 当从服务器断开

function OnDisconnectedFromServer (mode : NetworkDisconnection) : void

Description描述

Called on client during disconnection from server, but also on the server when the connection has disconnected.

在服务器上当连接已经断开,在客户端调用这个函数,但当连接已经被禁用,也在服务器上调用。

When called on the client the connection was lost or you disconnected from the server. The NetworkDisconnection enum will indicate if the connection was cleanly disconnected or if the connection was lost. When called on the server the connection has successfully disconnected (after a call to Network.Disconnect).

当这个连接已经丢失或从服务器断开,在客户端调用这个函数。NetworkDisconnection枚举将表示,如果连接已经干净断开或如果连接已经丢失。当在服务器上调用,该连接已经成功地断开(调用Network.Disconnect之后)。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnDisconnectedFromServer(NetworkDisconnection info) {
		if (Network.isServer)
			Debug.Log("Local server connection disconnected");
		else
			if (info == NetworkDisconnection.LostConnection)
				Debug.Log("Lost connection to the server");
			else
				Debug.Log("Successfully diconnected from the server");
	}
}
function OnDisconnectedFromServer(info : NetworkDisconnection) {
	if (Network.isServer) {
	Debug.Log("Local server connection disconnected");
	}
	else {
		if (info == NetworkDisconnection.LostConnection)
			Debug.Log("Lost connection to the server");
		else
			Debug.Log("Successfully diconnected from the server");
	}
}
Page last updated: 2011-5-9