4using System.Threading.Tasks;
26 : base(
"Xmpp/PopMessages",
27 new KeyValuePair<Type,
Expression>(typeof(Dictionary<string, object>), new
Expression(jsonPattern)),
53 int MaxCount =
int.MaxValue;
55 if (Parameters.TryGetValue(
"PMaxCount", out
IElement E) && !(E is
null) &&
56 E.AssociatedObjectValue is
double d2)
61 Task
_ = Task.Run(async () =>
67 List<object> Messages2 =
new List<object>();
68 IEnumerable<IOfflineMessage> Messages;
73 if (!(Messages is
null))
77 StringBuilder Xml =
new StringBuilder();
78 Xml.Append(
"<message xmlns='");
82 Xml.Append(
"</message>");
84 XmlDocument Doc =
XML.
ParseXml(Xml.ToString(),
true);
89 {
"from", Message.From.Value },
90 {
"to", Message.To.Value },
91 {
"lang", Message.Language },
92 {
"type", Message.Type },
93 {
"timestamp", Message.Timestamp },
94 {
"Content", Doc.DocumentElement.ChildNodes }
104 Result[
"Messages"] = Messages2.ToArray();
106 await Response.
Return(Result);
111 catch (XmlException ex)
121 return Task.CompletedTask;
A Named dictionary is a dictionary, with a local name and a namespace. Use it to return content that ...
Helps with common XML-related tasks.
static XmlException AnnotateException(XmlException ex)
Creates a new XML Exception object, with reference to the source XML file, for information.
static XmlDocument ParseXml(string Xml)
Parses an XML Document from its string representation.
Represents an HTTP request.
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
Task Return(Exception ex)
Returns an error to the client.
Abstract base class for XMPP client connections
const string C2SNamespace
jabber:client
Static class managing loading of resources stored as embedded resources or in content files.
static string LoadResourceAsText(string ResourceName)
Loads a text resource from an embedded resource.
Class managing a script expression.
string UserName
User Name.
async Task DeleteOfflineMessages(IEnumerable< IOfflineMessage > Messages)
Deletes offline messages.
async Task< IEnumerable< IOfflineMessage > > GetOfflineMessages(CaseInsensitiveString ToUserName, int Max)
Gets the oldest offline messages stored for a given bare JID, up to a maximum count.
static AccountUser AssertUserAuthenticated(HttpRequest Request)
Makes sure the request is made by an authenticated API user.
const string AgentNamespace
https://waher.se/Schema/BrokerAgent.xsd
Abstract base class for XMPP resources.
Pops offline messages available for the account.
PopMessages()
Pops offline messages available for the account.
override bool Synchronous
If the resource is synchronous (i.e. returns a response in the method handler), or if it is asynchron...
override Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.
Interface for offline messages.
string ContentXml
Message content.
Basic interface for all types of elements.