## 6 Implementation
### User Applications  
Appdaptivity does not focus on a certain user application, but it paves the way to the integration of them into the system. To integrate external end users with Appdaptivity, an application should be defined with a WebSocket communication, which should understand the API defined. Moreover, the application should provide the capabilities to visualize the behaviours defined (e.g., real-time charts) and enable end users to interact with the system (e.g., group of actuators). Lastly, NFC reading capabilities will be required to change the location. To validate Appdaptivity we have created a smartphone user application. Smartphones have revolutionised the way in which we interact with each other and we use applications. Moreover, they are commonly used nowadays, and through them the release of a smartphone can be quickly extended amongst end users. To avoid the programming efforts in programming smartphone applications for different OSs, we chose a multi-platform framework for developing smartphone applications called Ionic [40]. The Ionic framework enables the application programming using web technologies such as HTML and JavaScript. It is based on AngularJS, a well-known framework for creating web applications. Once applications have been implemented in Ionic, they can be compiled for the target mobile OS such as Android and IOS. This reduces the development effort since only one source code is maintained.  
Figure 8: Alert message sent from the PoCo to an user application.  
The resulting smartphone application enables end users to switch locations using the NFC technology and render the behaviours as defined in the PoCo (e.g., charts, group of actuators and real-time values). Apart from the location flow, end users can also activate the building flow obtaining all the behaviours defined in the building where they are. Furthermore, the smartphone application provides support for network discovery required in Appdaptivity cloud deployments. Figure 7 shows some screenshots of the resulting application running some behaviours defined in the PoCo such as charts and group of lights once a location has been established. Although the application is intended to be installed in multiple mobile OSs, currently the application only offers support for the tested OS: Android.  
In certain situations, user applications have to perform a network discovery, like, for example, the RD discovery in a cloud deployment. The RD can be discovered through IPv6 multicast using its defined interface. However, during the development of a smartphone app as a user application in Appdaptivity, we realised that IPv6 multicast was not working properly in some devices, especially in smartphones. In this case, we extended the Appdaptivity with multicast Domain Name System (mDNS), a zero-configuration service--it does not require manual configuration nor special servers--which shares similarities with DNS and resolves hostnames to IP addresses. mDNS is supported by Android and IOS OSs, and the open source implementation known as avahi, which has become the de facto standard implementation in Linux. In fact, the mDNS support in Appdaptivity uses the avahi implementation to publish a service on an established IP where clients can discover the RD in those cases where IPv6 multicast does not work properly. Smartphone-based user applications can make use of this service in order to reduce the issues using IPv6 multicast as in our case.