2using System.Threading.Tasks;
41 StringBuilder Xml =
new StringBuilder();
42 TaskCompletionSource<bool> Result =
new TaskCompletionSource<bool>();
44 Xml.Append(
"<uri xmlns=\"");
49 Xml.Append(
"\" for=\"");
50 Xml.Append(
XML.
Encode(
this.Uri.To.Address));
54 Xml.Append(
"\" for=\"");
55 Xml.Append(
XML.
Encode(
this.Uri.State.Sender));
59 Xml.Append(
XML.
Encode(
this.Uri.UriString));
65 string.Empty, Xml.
ToString(), (sender2, e2) =>
68 this.Uri.State.Error(e2.ErrorType.ToString().ToLower(), string.Empty, this.Uri.PrincipalDomain +
" reports: " + e2.ErrorText);
70 Result.TrySetResult(e2.Ok);
72 return Task.CompletedTask;
76 this.
Uri.
State.Error(Uris.States.EDalerUriErrorType.ServiceUnavailable,
"Unable to relay URI to secondary domain.",
false);
80 return await Result.Task;
89 return this.DoCommand(
"execute");
92 private async Task<bool> DoCommand(
string Command)
94 StringBuilder Xml =
new StringBuilder();
95 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
99 Xml.Append(
" xmlns=\"");
101 Xml.Append(
"\" id=\"");
102 Xml.Append(this.
Uri.
Id.ToString());
108 string.Empty, Xml.
ToString(), (sender2, e2) =>
111 Result.TrySetResult(null);
113 Result.TrySetResult(string.IsNullOrEmpty(e2.ErrorText) ?
"Unable to process request." : e2.ErrorText);
115 return Task.CompletedTask;
122 string Msg = await Result.Task;
123 if (
string.IsNullOrEmpty(Msg))
126 this.
Uri.
State.Error(Uris.States.EDalerUriErrorType.ServiceUnavailable,
"Secondary domain rejected the request: " + Msg,
false);
136 return this.DoCommand(
"commit");
145 return this.DoCommand(
"rollback");
Helps with common XML-related tasks.
static string Encode(string s)
Encodes a string for use in XML.
XmppServer Server
XMPP Server.
Contains information about one XMPP address.
override string ToString()
object.ToString()
Task< bool > SendIqRequest(string Type, string From, string To, string Language, string ContentXml, EventHandlerAsync< IqResultEventArgs > Callback, object State)
Sends an IQ stanza to a recipient.
CaseInsensitiveString Domain
Domain name.
async Task< CaseInsensitiveString > FindComponentAsync(CaseInsensitiveString Jid, CaseInsensitiveString Feature)
Finds a component having a specific feature, servicing a JID.
Represents a case-insensitive string.
Manages eDaler on accounts connected to the broker.
const string NamespaceEDaler
Namespace of eDaler component.
Abstract base class for eDaler transactions.
Relays partial processing of the URI to the secondary domain.
override async Task< bool > DoPrepare()
Performs actual preparation.
CaseInsensitiveString Domain
secondary domain.
override Task< bool > DoExecute()
Performs actual execution.
RelayToSecondary(EDalerUri Uri, CaseInsensitiveString Domain)
Relays partial processing of the URI to the secondary domain.
override Task< bool > DoRollback()
Performs actual rollback.
override Task< bool > DoCommit()
Performs actual commit.
Abstract base class for eDaler URIs
EntityType ToType
Type of recipient.
EDalerUriState State
URI State object.
EDalerComponent EDaler
eDaler component reference
EntityType
Type of entity referred to in transaction.