You're in luck: Some people already thought of this, submitted an RFC to the IETF and implemented it. It goes by the name XMPP.