refactored registration
one bug left: could not received the first message when a session is
initialized by other partners