We now have sufficient information to begin using XMPP in our projects. To do this, we create two new projects, which we will call SensorXmpp and ActuatorXmpp, copying the corresponding code from the Sensor and Actuator projects as we have done earlier. As with the previous chapters, we use the same hardware.
We also add a series of NuGet packages to our projects:
NuGet |
Description |
Waher.Networking.XMPP.UWP |
XMPP client library. |
Waher.Networking.XMPP.Sensor.UWP |
XMPP IoT sensor data plugin. Added to both projects. |
Waher.Networking.XMPP.Chat.UWP |
XMPP IoT chat plugin. |
Waher.Networking.XMPP.Control.UWP |
XMPP IoT control plugin. Only added to the ActuatorXmpp project. |
Waher.Networking.XMPP.Provisioning.UWP |
Added to both projects. We will discuss this module in a later chapter. |
When we initialize our runtime environment, we must make sure to include the assemblies defining relevant classes, at the beginning of the application. We will include the capability of using a rich chat environment using the formatted syntax (based on markdown) and graphs (based on the script engine), so we include these assemblies as well:
Types.Initialize( typeof(FilesProvider).GetTypeInfo().Assembly, typeof(RuntimeSettings).GetTypeInfo().Assembly, typeof(IContentEncoder).GetTypeInfo().Assembly, typeof(XmppClient).GetTypeInfo().Assembly, typeof(Waher.Content.Markdown.MarkdownDocument). GetTypeInfo().Assembly, typeof(Waher.Content.Xml.XML).GetTypeInfo().Assembly, typeof(Waher.Script.Expression).GetTypeInfo().Assembly, typeof(Waher.Script.Graphs.Graph).GetTypeInfo().Assembly, typeof(App).GetTypeInfo().Assembly);
<Capability Name="internetClientServer" />