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.
28 lines
661 B
28 lines
661 B
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); |
|
}
|
|
|