Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MucExtension.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
4using System.Xml;
8
10{
15 {
16 private string componentAddress;
17
24 : base(Parent, Model)
25 {
26 }
27
31 public override string LocalName => nameof(MucExtension);
32
40 {
41 return new MucExtension(Parent, Model);
42 }
43
48 public override Task FromXml(XmlElement Definition)
49 {
50 this.componentAddress = XML.Attribute(Definition, "componentAddress");
51
52 return base.FromXml(Definition);
53 }
54
61 public override Task<object> Add(IActor Instance, Waher.Networking.XMPP.XmppClient Client)
62 {
63 MultiUserChatClient Extension = new MultiUserChatClient(Client, this.componentAddress);
64 Client.SetTag("MUC", Extension);
65
66 Extension.OccupantPresence += (Sender, e) =>
67 {
68 this.Model.ExternalEvent(Instance, "OccupantPresence",
69 new KeyValuePair<string, object>("e", e),
70 new KeyValuePair<string, object>("Client", Client));
71
72 return Task.CompletedTask;
73 };
74
75 Extension.OccupantRequest += (Sender, e) =>
76 {
77 this.Model.ExternalEvent(Instance, "OccupantRequest",
78 new KeyValuePair<string, object>("e", e),
79 new KeyValuePair<string, object>("Client", Client));
80
81 return Task.CompletedTask;
82 };
83
84 Extension.PrivateMessageReceived += (Sender, e) =>
85 {
86 this.Model.ExternalEvent(Instance, "PrivateMessageReceived",
87 new KeyValuePair<string, object>("e", e),
88 new KeyValuePair<string, object>("Client", Client));
89
90 return Task.CompletedTask;
91 };
92
93 Extension.RegistrationRequest += (Sender, e) =>
94 {
95 this.Model.ExternalEvent(Instance, "RegistrationRequest",
96 new KeyValuePair<string, object>("e", e),
97 new KeyValuePair<string, object>("Client", Client));
98
99 return Task.CompletedTask;
100 };
101
102 Extension.RoomDeclinedInvitationReceived += (Sender, e) =>
103 {
104 this.Model.ExternalEvent(Instance, "RoomDeclinedInvitationReceived",
105 new KeyValuePair<string, object>("e", e),
106 new KeyValuePair<string, object>("Client", Client));
107
108 return Task.CompletedTask;
109 };
110
111 Extension.RoomDestroyed += (Sender, e) =>
112 {
113 this.Model.ExternalEvent(Instance, "RoomDestroyed",
114 new KeyValuePair<string, object>("e", e),
115 new KeyValuePair<string, object>("Client", Client));
116
117 return Task.CompletedTask;
118 };
119
120 Extension.RoomInvitationReceived += (Sender, e) =>
121 {
122 this.Model.ExternalEvent(Instance, "RoomInvitationReceived",
123 new KeyValuePair<string, object>("e", e),
124 new KeyValuePair<string, object>("Client", Client));
125
126 return Task.CompletedTask;
127 };
128
129 Extension.RoomMessage += (Sender, e) =>
130 {
131 this.Model.ExternalEvent(Instance, "RoomMessage",
132 new KeyValuePair<string, object>("e", e),
133 new KeyValuePair<string, object>("Client", Client));
134
135 return Task.CompletedTask;
136 };
137
138 Extension.RoomOccupantMessage += (Sender, e) =>
139 {
140 this.Model.ExternalEvent(Instance, "RoomOccupantMessage",
141 new KeyValuePair<string, object>("e", e),
142 new KeyValuePair<string, object>("Client", Client));
143
144 return Task.CompletedTask;
145 };
146
147 Extension.RoomPresence += (Sender, e) =>
148 {
149 this.Model.ExternalEvent(Instance, "RoomPresence",
150 new KeyValuePair<string, object>("e", e),
151 new KeyValuePair<string, object>("Client", Client));
152
153 return Task.CompletedTask;
154 };
155
156 Extension.RoomSubject += (Sender, e) =>
157 {
158 this.Model.ExternalEvent(Instance, "RoomSubject",
159 new KeyValuePair<string, object>("e", e),
160 new KeyValuePair<string, object>("Client", Client));
161
162 return Task.CompletedTask;
163 };
164
165 return Task.FromResult<object>(Extension);
166 }
167
168 }
169}
Root node of a simulation model
Definition: Model.cs:49
bool ExternalEvent(IExternalEventsNode Source, string Name, params KeyValuePair< string, object >[] Arguments)
Method called when an external event has been received.
Definition: Model.cs:889
Multi-User Chat XMPP extension
Definition: MucExtension.cs:15
override Task FromXml(XmlElement Definition)
Sets properties and attributes of class in accordance with XML definition.
Definition: MucExtension.cs:48
override Task< object > Add(IActor Instance, Waher.Networking.XMPP.XmppClient Client)
Adds the extension to the client.
Definition: MucExtension.cs:61
override ISimulationNode Create(ISimulationNode Parent, Model Model)
Creates a new instance of the node.
Definition: MucExtension.cs:39
override string LocalName
Local name of XML element defining contents of class.
Definition: MucExtension.cs:31
MucExtension(ISimulationNode Parent, Model Model)
Multi-User Chat XMPP extension
Definition: MucExtension.cs:23
Abstract base class for XMPP extensions.
Helps with common XML-related tasks.
Definition: XML.cs:19
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Definition: XML.cs:914
Client managing communication with a Multi-User-Chat service. https://xmpp.org/extensions/xep-0045....
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Definition: XmppClient.cs:59
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
ISimulationNode Parent
Parent node in the simulation model.
Basic interface for simulator nodes. Implementing this interface allows classes with default contruct...
Definition: IActor.cs:11
Definition: App.xaml.cs:4