Add convenience Call ctor for Message
This commit is contained in:
parent
a8b227ec1c
commit
8e1da8c190
|
@ -108,12 +108,7 @@ namespace Ooui
|
||||||
|
|
||||||
protected void SendCall (string methodName, params object[] args)
|
protected void SendCall (string methodName, params object[] args)
|
||||||
{
|
{
|
||||||
Send (new Message {
|
Send (Message.Call (Id, methodName, args));
|
||||||
MessageType = MessageType.Call,
|
|
||||||
TargetId = Id,
|
|
||||||
Key = methodName,
|
|
||||||
Value = args,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void SendSet (string attributeName, object value)
|
protected void SendSet (string attributeName, object value)
|
||||||
|
|
|
@ -22,6 +22,13 @@ namespace Ooui
|
||||||
[JsonProperty("v")]
|
[JsonProperty("v")]
|
||||||
public object Value = null;
|
public object Value = null;
|
||||||
|
|
||||||
|
public static Message Call (string targetId, string method, params object[] args) => new Message {
|
||||||
|
MessageType = MessageType.Call,
|
||||||
|
TargetId = targetId,
|
||||||
|
Key = method,
|
||||||
|
Value = args,
|
||||||
|
};
|
||||||
|
|
||||||
public static Message Event (string targetId, string eventType) => new Message {
|
public static Message Event (string targetId, string eventType) => new Message {
|
||||||
MessageType = MessageType.Event,
|
MessageType = MessageType.Event,
|
||||||
TargetId = targetId,
|
TargetId = targetId,
|
||||||
|
|
|
@ -353,12 +353,8 @@ namespace Ooui
|
||||||
//
|
//
|
||||||
// Add it to the document body
|
// Add it to the document body
|
||||||
//
|
//
|
||||||
await SendMessageAsync (webSocket, new Message {
|
await SendMessageAsync (webSocket, Message.Call ("document.body", "appendChild", element),
|
||||||
TargetId = "document.body",
|
element, createdIds, token).ConfigureAwait (false);
|
||||||
MessageType = MessageType.Call,
|
|
||||||
Key = "appendChild",
|
|
||||||
Value = new[] { element },
|
|
||||||
}, element, createdIds, token).ConfigureAwait (false);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Listen for events
|
// Listen for events
|
||||||
|
|
Loading…
Reference in New Issue