2using System.Threading.Tasks;
41 !await
this.Uri.EDaler.Legal.InSameTreeOfTrust(
this.Uri.SecondaryDomain.Value))
43 this.
Uri.
State.Error(Uris.States.EDalerUriErrorType.Forbidden,
44 "Secondary domain (" +
this.Uri.SecondaryDomain.Value +
45 ") not in same tree of trust.",
false);
51 StringBuilder Xml =
new StringBuilder();
52 TaskCompletionSource<bool> Result =
new TaskCompletionSource<bool>();
54 Xml.Append(
"<uri xmlns=\"");
59 Xml.Append(
"\" for=\"");
60 Xml.Append(
XML.
Encode(
this.Uri.To.Address));
64 Xml.Append(
"\" for=\"");
65 Xml.Append(
XML.
Encode(
this.Uri.State.Sender));
69 Xml.Append(
XML.
Encode(
this.Uri.UriString));
75 string.Empty, Xml.
ToString(),
false, (sender2, e2) =>
78 this.Uri.State.Error(e2.ErrorType.ToString().ToLower(), string.Empty, this.Uri.PrincipalDomain +
" reports: " + e2.ErrorText);
80 Result.TrySetResult(e2.Ok);
82 return Task.CompletedTask;
86 this.
Uri.
State.Error(Uris.States.EDalerUriErrorType.ServiceUnavailable,
"Unable to relay URI to secondary domain.",
false);
90 return await Result.Task;
99 return this.DoCommand(
"execute");
102 private async Task<bool> DoCommand(
string Command)
104 StringBuilder Xml =
new StringBuilder();
105 TaskCompletionSource<string> Result =
new TaskCompletionSource<string>();
109 Xml.Append(
" xmlns=\"");
111 Xml.Append(
"\" id=\"");
112 Xml.Append(this.
Uri.
Id.ToString());
118 string.Empty, Xml.
ToString(),
false, (sender2, e2) =>
121 Result.TrySetResult(null);
123 Result.TrySetResult(string.IsNullOrEmpty(e2.ErrorText) ?
"Unable to process request." : e2.ErrorText);
125 return Task.CompletedTask;
132 string Msg = await Result.Task;
133 if (
string.IsNullOrEmpty(Msg))
136 this.
Uri.
State.Error(Uris.States.EDalerUriErrorType.ServiceUnavailable,
"Secondary domain rejected the request: " + Msg,
false);
146 return this.DoCommand(
"commit");
155 return this.DoCommand(
"rollback");
Helps with common XML-related tasks.
static string Encode(string s)
Encodes a string for use in XML.
Static class managing the runtime environment of the IoT Gateway.
static bool HasDomain
If a domain name is configured.
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.