private void OnDestroy() { nsm.RemoveEventListener(this); nsm.Dispose(); nsm = null; Debug.Log("Stop Game!"); }
// Start is called before the first frame update void Start() { Debug.Log("Start Game!"); nsm = NetworkServiceManager.Instance; nsm.Start(AppProtocol.MAX_CHANNELS, new SampleNetworkPacketHandler()); nsm.ListenAt("127.0.0.1", AppProtocol.PORT, AppProtocol.SERVER_CHANNEL); // 启动本地TCP服务 nsm.AddEventListener(this); }