Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DeletePubSubNode.cs
1using System.Threading.Tasks;
7
9{
11 {
12 public DeletePubSubNode()
13 : base("/DeletePubSubNode")
14 {
15 }
16
17 public override bool HandlesSubPaths => false;
18 public override bool UserSessions => true;
19 public bool AllowsPOST => true;
20
21 public async Task POST(HttpRequest Request, HttpResponse Response)
22 {
23 Gateway.AssertUserAuthenticated(Request, "Admin.Broker.XMPP.PubSub");
24
25 if (!Request.HasData)
26 throw new BadRequestException();
27
28 object Obj = await Request.DecodeDataAsync();
29 if (!(Obj is string NodeName))
30 throw new BadRequestException();
31
32 PubSubNode PubSubNode = await XmppServerModule.GetPubSubNodeAsync(NodeName);
33 if (PubSubNode is null)
34 throw new NotFoundException();
35
36 await XmppServerModule.PubSub.DeleteNode(string.Empty, PubSubNode,
38
39 XmppServerModule.Instance.WebNodeStatus(NodeName, false);
40
41 Response.StatusCode = 200;
42 Response.ContentType = PlainTextCodec.DefaultContentType;
43 await Response.Write("1");
44 }
45 }
46}
Plain text encoder/decoder.
const string DefaultContentType
text/plain
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:126
static IUser AssertUserAuthenticated(HttpRequest Request, string Privilege)
Makes sure a request is being made from a session with a successful user login.
Definition: Gateway.cs:3041
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
Definition: HttpRequest.cs:18
bool HasData
If the request has data.
Definition: HttpRequest.cs:74
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Definition: HttpRequest.cs:95
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:21
async Task Write(byte[] Data)
Returns binary data in the response.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
The server has not found anything matching the Request-URI. No indication is given of whether the con...
XmppAddress MainDomain
Main/principal domain address
Definition: Component.cs:86
Contains information about one XMPP address.
Definition: XmppAddress.cs:9
CaseInsensitiveString Address
XMPP Address
Definition: XmppAddress.cs:37
Defines a node on which items can be published.
Definition: PubSubNode.cs:19
CaseInsensitiveString Domain
Domain
Definition: PubSubNode.cs:133
bool AllowsPOST
If the POST method is allowed.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
Service Module hosting the XMPP broker and its components.
POST Interface for HTTP resources.