private void initSession(ClientSession session) throws UserNotFoundException {

        // Only user sessions need to be authenticated
        if (userManager.isRegisteredUser(session.getAddress(), false)) {
            String username = session.getAddress().getNode();

            // Send pending subscription requests to user if roster service is enabled
            if (RosterManager.isRosterServiceEnabled()) {
                Roster roster = rosterManager.getRoster(username);
                for (RosterItem item : roster.getRosterItems()) {
                    if (item.getRecvStatus() == RosterItem.RecvType.SUBSCRIBE) {
                        Presence presence = item.getSubscribeStanza();
                        presence.setTo(session.getAddress().asBareJID());
                        session.process(presence);
                    } else if (item.getRecvStatus() == RosterItem.RecvType.UNSUBSCRIBE) {
                        session.process(createSubscribePresence(item.getJid(),
                                session.getAddress().asBareJID(), false));
                    }
                    if (item.getSubStatus() == RosterItem.SUB_TO
                            || item.getSubStatus() == RosterItem.SUB_BOTH) {
                        presenceManager.probePresence(session.getAddress(), item.getJid());
                    }
                }
            }
            if (session.canFloodOfflineMessages()) {
                // deliver offline messages if any
                Collection<OfflineMessage> messages = messageStore.getMessages(username, true);
                for (Message message : messages) {
                    session.process(message);
                }
            }
        }
    }
A session that has transitioned to available status must be initialized.
This includes:
<ul>
<li>Sending all offline presence subscription requests</li>
<li>Sending offline messages</li>
</ul>

@param session The session being updated
@throws UserNotFoundException If the user being updated does not exist
xmppserver/src/main/java/org/jivesoftware/openfire/handler/PresenceUpdateHandler.java