Shared code between the IM client and server