Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Rooms.cs
1using System.Text;
2using System.Threading.Tasks;
4
6{
11 {
15 public Rooms()
16 : base()
17 {
18 }
19
23 public override string Name => "Rooms";
24
28 public override string[] HelpParagraphs => new string[]
29 {
30 "Lists rooms currently entered by the Neuron."
31 };
32
40 public override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, ResponseCallbackHandler ResponseCallback)
41 {
42 if (Gateway.MucClient is null)
43 {
44 await ResponseCallback("Multi-User Chat disabled.", string.Empty);
45 return;
46 }
47
48 RoomInfo[] Rooms = XmppServerModule.Instance.GetRooms();
49
50 if (Rooms?.Length == 0)
51 {
52 await ResponseCallback("No rooms entered.", string.Empty);
53 return;
54 }
55
56 StringBuilder Response = new StringBuilder();
57
58 Response.AppendLine("| Rooms ||||");
59 Response.AppendLine("| Nick-name | Room | Domain | Type |");
60 Response.AppendLine("|:----|:----|:----|:----|");
61
62 foreach (RoomInfo Room in Rooms)
63 {
64 Response.Append("| `");
65 Response.Append(Room.NickName);
66 Response.Append("` | `");
67 Response.Append(Room.RoomId);
68 Response.Append("` | `");
69 Response.Append(Room.Domain);
70 Response.Append("` | ");
71
72 if (Room.Permanent)
73 Response.Append("Permanent");
74 else
75 Response.Append("Temporary");
76
77 Response.AppendLine(" |");
78 }
79
80 await ResponseCallback(Response.ToString(), string.Empty);
81 }
82 }
83}
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:126
static MultiUserChatClient MucClient
XMPP Multi-User Chat Protocol (MUC) Client.
Definition: Gateway.cs:3267
An administrative command with no parameters.
Multi-User Chat Room information
Definition: RoomInfo.cs:7
string NickName
Nick-name to use in room.
Definition: RoomInfo.cs:56
bool Permanent
If room association should be persisted.
Definition: RoomInfo.cs:66
Lists rooms currently entered by the neuron.
Definition: Rooms.cs:11
override string Name
Command name
Definition: Rooms.cs:23
override string[] HelpParagraphs
Markdown description of syntax.
Definition: Rooms.cs:28
override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, ResponseCallbackHandler ResponseCallback)
Executes the command.
Definition: Rooms.cs:40
Rooms()
Lists rooms currently entered by the neuron.
Definition: Rooms.cs:15
Service Module hosting the XMPP broker and its components.
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.