如果客户端尝试连接到不存在的服务器,如何检查错误?
我的代码!
//Server
void Start () {
NetworkServer.Listen(13044);
}
//Client
NetworkClient thisclient = new NetworkClient ();
thisclient.Connect ("127.0.0.1", 13044);
thisclient.RegisterHandler(MsgType.Error, errortest);
thisclient.RegisterHandler (MsgType.Disconnect, dctest);
void errortest(NetworkMessage netMsg){
var errorMsg = netMsg.ReadMessage<ErrorMessage>();
Debug.Log("Error:" + errorMsg.errorCode);}
void dctest(NetworkMessage netMsg){
//if I run the client while the server is not present, its goes here instead of errortest
}