You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
661 B
29 lines
661 B
4 years ago
|
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);
|
||
|
}
|