public void Init() { m_net = new NetManager(); m_net.Init(typeof(KCPConnection), ServerID.ZoneServer, 0); m_net.RegisterRPCListener(this); GlobalEvent.onUpdate.AddListener(OnUpdate); m_heartbeat = new HeartBeatHandler(); m_heartbeat.Init(m_net); m_heartbeat.onTimeout.AddListener(OnHeartBeatTimeout); }
public void Clean() { GlobalEvent.onUpdate.RemoveListener(OnUpdate); if (m_net != null) { m_net.Clean(); m_net = null; } if (m_heartbeat != null) { m_heartbeat.onTimeout.RemoveListener(OnHeartBeatTimeout); m_heartbeat.Clean(); m_heartbeat = null; } }