Cleanup send functions
This commit is contained in:
parent
592b7e4bc2
commit
0683cf91ed
|
@ -22,7 +22,12 @@ namespace Ooui
|
|||
protected EventTarget (string tagName)
|
||||
{
|
||||
TagName = tagName;
|
||||
SendCreate ();
|
||||
|
||||
Send (new Message {
|
||||
MessageType = MessageType.Create,
|
||||
TargetId = Id,
|
||||
Key = TagName,
|
||||
});
|
||||
}
|
||||
|
||||
public void AddEventListener (string eventType, EventHandler handler)
|
||||
|
@ -41,7 +46,7 @@ namespace Ooui
|
|||
handlers.Add (handler);
|
||||
|
||||
if (sendListen)
|
||||
SendListen (eventType);
|
||||
Send (Message.Listen (Id, eventType));
|
||||
}
|
||||
|
||||
public void RemoveEventListener (string eventType, EventHandler handler)
|
||||
|
@ -74,19 +79,10 @@ namespace Ooui
|
|||
|
||||
public virtual void Send (Message message)
|
||||
{
|
||||
SaveStateMessage (message);
|
||||
SaveStateMessageIfNeeded (message);
|
||||
MessageSent?.Invoke (message);
|
||||
}
|
||||
|
||||
protected void SendCreate ()
|
||||
{
|
||||
Send (new Message {
|
||||
MessageType = MessageType.Create,
|
||||
TargetId = Id,
|
||||
Key = TagName,
|
||||
});
|
||||
}
|
||||
|
||||
protected void SendCall (string methodName, params object[] args)
|
||||
{
|
||||
Send (new Message {
|
||||
|
@ -107,15 +103,6 @@ namespace Ooui
|
|||
});
|
||||
}
|
||||
|
||||
protected void SendListen (string eventType)
|
||||
{
|
||||
Send (new Message {
|
||||
MessageType = MessageType.Listen,
|
||||
TargetId = Id,
|
||||
Key = eventType,
|
||||
});
|
||||
}
|
||||
|
||||
public virtual void Receive (Message message)
|
||||
{
|
||||
if (message == null)
|
||||
|
|
Loading…
Reference in New Issue