2using System.Collections.Generic;
4using System.Threading.Tasks;
25 : base(
"Xmpp/PopMessages",
26 new KeyValuePair<Type,
Expression>(typeof(Dictionary<string, object>), new
Expression(jsonPattern)),
52 int MaxCount =
int.MaxValue;
54 if (Parameters.TryGetValue(
"PMaxCount", out
IElement E) && !(E is
null) &&
55 E.AssociatedObjectValue is
double d2)
60 Task _ = Task.Run(async () =>
66 List<object> Messages2 =
new List<object>();
67 IEnumerable<IOfflineMessage> Messages;
72 if (!(Messages is
null))
76 StringBuilder Xml =
new StringBuilder();
77 Xml.Append(
"<message xmlns='");
81 Xml.Append(
"</message>");
83 XmlDocument Doc =
new XmlDocument()
85 PreserveWhitespace =
true
87 Doc.LoadXml(Xml.ToString());
89 Messages2.Add(
new Dictionary<string, object>()
92 {
"from", Message.From.Value },
93 {
"to", Message.To.Value },
94 {
"lang", Message.Language },
95 {
"type", Message.Type },
96 {
"timestamp", Message.Timestamp },
97 {
"Content", Doc.DocumentElement.ChildNodes }
107 Result[
"Messages"] = Messages2.ToArray();
109 await Response.
Return(Result);
114 catch (XmlException ex)
124 return Task.CompletedTask;
A Named dictionary is a dictionary, with a local name and a namespace. Use it to return content that ...
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.
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.
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...
async Task Return(object Object)
Returns an object to the client. This method can only be called once per response,...
Abstract base class for XMPP client connections
const string C2SNamespace
jabber:client
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.