2using System.Collections.Generic;
4using System.Threading.Tasks;
41 private string responseVariable;
83 public override Task
FromXml(XmlElement Definition)
88 this.responseVariable =
XML.
Attribute(Definition,
"responseVariable");
90 return base.FromXml(Definition);
99 if (this.value is
null)
102 throw new Exception(
"Value already registered.");
113 object Content = this.value is
null ? string.Empty : await this.value.
EvaluateAsync(
Variables) ??
string.Empty;
117 throw new Exception(
"Actor not an XMPP client.");
119 if (Content is XmlDocument Doc)
121 else if (Content is XmlElement E)
124 throw new Exception(
"Requests must be XML.");
126 TaskCompletionSource<LinkedListNode<IActivityNode>> T =
new TaskCompletionSource<LinkedListNode<IActivityNode>>();
132 Variables[this.responseVariable] = e.FirstElement;
133 T.TrySetResult(
null);
136 T.TrySetException(
new XmppException(
string.IsNullOrEmpty(e.ErrorText) ?
"Error response returned." : e.ErrorText));
138 return Task.CompletedTask;
150 public override void ExportPlantUml(StreamWriter Output,
int Indentation,
char QuoteChar)
152 base.ExportPlantUml(Output, Indentation, QuoteChar);
154 Indent(Output, Indentation);
156 Output.Write(this.actor.
Value);
157 Output.Write(
".Request");
165 if (!(this.value is
null))
173 Output.WriteLine(
");");
Root node of a simulation model
Abstract base class for activity nodes
async Task< object > GetActorObjectAsync(StringAttribute Actor, Variables Variables)
Gets an actor object, given a string representation, possibly containing script, of the actor.
static void Indent(StreamWriter Output, int Indentation)
Adds indentation to the current row.
Contains the value of a string attribute, possibly with embedded script.
async Task< string > GetValueAsync(Variables Variables)
Gets the value of the attribute.
string Value
String value, from definition
Abstract base class for values
Sends a custom IQ request to a recipient
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
void Register(IValue Value)
Registers a value for the argument.
override string LocalName
Local name of XML element defining contents of class.
override async Task< LinkedListNode< IActivityNode > > Execute(Variables Variables)
Executes a node.
override Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
override string SchemaResource
Points to the embedded XML Schema resource defining the semantics of the XML namespace.
Request(ISimulationNode Parent, Model Model)
Sends a custom IQ request to a recipient
override void ExportPlantUml(StreamWriter Output, int Indentation, char QuoteChar)
Exports PlantUML
override string Namespace
XML Namespace where the element is defined.
Sends a custom message to a recipient
static void AppendArgument(StreamWriter Output, int Indentation, string Name, string Value, bool Quotes, char QuoteChar)
Appends an argument
Object used in simulation activities.
Abstract base class for XMPP actors.
XmppClient Client
XMPP Client
const string XmppSchema
TAG.Simulator.XMPP.Schema.ComSimXmpp.xsd
const string XmppNamespace
http://lab.tagroot.io/Schema/ComSim/XMPP.xsd
Helps with common XML-related tasks.
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
int DefaultRetryTimeout
Default retry timeout, in milliseconds. This value is used when sending IQ requests wihtout specifyin...
bool DefaultDropOff
Default Drop-off value. If drop-off is used, the retry timeout is doubled for each retry,...
int DefaultNrRetries
Default number of retries if results or errors are not returned. This value is used when sending IQ r...
int DefaultMaxRetryTimeout
Default maximum retry timeout, in milliseconds. This value is used when sending IQ requests wihtout s...
Task< uint > SendIq(string Id, string To, string Xml, string Type, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Sends an IQ stanza.
Base class of XMPP exceptions
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
ISimulationNode Parent
Parent node in the simulation model.
Task< object > EvaluateAsync(Variables Variables)
Evaluates the value.
Interface for nodes holding a value node
RequestType
Type of IQ request