Added reconnect functionality for XMPP

Reconnection loop runs in another thread, also added locking mechanism
to keep init() synchronous