See InstaChatX project. This is the Server part