using UnityEngine; using AX.Network.Protocols; using AX.NetworkSystem; public abstract class NetworkMessageBehaviour : MonoBehaviour { public virtual string MessageType { get { return this.GetType().Name; } } protected virtual void OnEnable() { NetworkMessageDispatcher.AddListener(MessageType, Execute); } protected virtual void OnDisable() { NetworkMessageDispatcher.RemoveListener(MessageType, Execute); } protected virtual void OnDestroy() { NetworkMessageDispatcher.RemoveListener(MessageType, Execute); } protected abstract void Execute(BinaryMessage message); }