using UnityEngine;
using TNet;
public class versiondemo : TNBehaviour
{
private static versiondemo instance = null;
public string address = "192.168.1.107";
public int port = 10420;
protected override void OnEnable()
{
base.OnEnable();
//subscribe to events
//both will provide version error
TNManager.onConnect += OnConnect;
TNManager.onError += OnError;
}
private void OnDisable()
{
TNManager.onConnect -= OnConnect;
TNManager.onError -= OnError;
}
private void Awake()
{
instance = this;
}
[ContextMenu("Connect")]
private void Connect()
{
if (instance == null) return;
TNManager.Connect(instance.address, instance.port);
}
private void OnError(string msg)
{
Debug.Log("OnError: " + msg);
//result:
//OnError: Version mismatch! Server is running a different protocol version!
}
private void OnConnect(bool success, string message)
{
Debug.Log(string.Format("OnConnect: success={0} message={1}", success, message));
//result:
//OnConnect: success=False message=Version mismatch! Server is running a different protocol version!
//if (!success && message == "...") dothis();
//else dothat();
}
}