webinos/Webinos-Platform — pull request #516 by aldafu (2013-03-12 14:44:47+00:00)
Title: Wp 851 disconnect events for rpc services

Jira-issues: [WP-850](http://jira.webinos.org/browse/WP-850), [WP-851](http://jira.webinos.org/browse/WP-851)

The first three commits clean up the MessageHandler by removing unused code, refactoring some duplicated code and rename some functions so it's more obvious what they do. That's for WP-850.

The last three commits (for WP-851) implement a way to let RPC services know when WRT or app disconnects/disappears. That way these RPC services can stop sending continous messages to entities that don't exist anymore as e.g. the Geolocation API service does when watchPosition is called.

This is achieved in two ways.

1. If the service is on the same PZ entity where the WRT was connected to (by WebSocket) immediately deliver a 'disconnect' event to all registered services on this PZ entity.
2. If the sending service is on a different PZ entity, send back a message of the new message type 'mprop' letting the original sender know that the entity disconnected. Again deliver a 'disconnect' event to all registered services on the PZ entity this message was received on.

The Geolocation geoip service uses this feature as an example.