当前位置: 首页>>代码示例>>Java>>正文


Java ClientSession.isInitialized方法代码示例

本文整理汇总了Java中org.jivesoftware.openfire.session.ClientSession.isInitialized方法的典型用法代码示例。如果您正苦于以下问题:Java ClientSession.isInitialized方法的具体用法?Java ClientSession.isInitialized怎么用?Java ClientSession.isInitialized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.openfire.session.ClientSession的用法示例。


在下文中一共展示了ClientSession.isInitialized方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isOnline

import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
@Override
public boolean isOnline(JID user) {
  long start = System.nanoTime();
  SessionManager sessionManager = getSessionManager();
  Collection<ClientSession> sessions = sessionManager.getSessions(user.getNode());
  boolean activeSession = false;
  for (ClientSession clientSession : sessions) {
    JID clientSessionAddress = clientSession.getAddress();
    //compare the node and the resource
    if (clientSessionAddress.getNode().equals(user.getNode()) && clientSessionAddress.getResource().equals(user.getResource())) {
      //if (clientSession.getAddress().equals(user)) {
      if (clientSession.isInitialized()) {
        activeSession = true;
        break;
      }
    }
  }
  long end = System.nanoTime();
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug(String.format ("For user:%s presence value:%s", user, activeSession));
    long delta = end - start;
    LOGGER.debug("Presence was checked in:" + (delta/1000) + " ms");
  }
  return activeSession;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:26,代码来源:MMXPresenceFinderImpl.java

示例2: routingFailed

import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
/**
 * Notification message indicating that a packet has failed to be routed to the recipient.
 *
 * @param recipient address of the entity that failed to receive the packet.
 * @param packet    Message packet that failed to be sent to the recipient.
 */
public void routingFailed( JID recipient, Packet packet )
{
    log.debug( "Message sent to unreachable address: " + packet.toXML() );
    final Message msg = (Message) packet;
    boolean storeOffline = true;


    if ( msg.getType().equals( Message.Type.chat ) && serverName.equals( recipient.getDomain() ) && recipient.getResource() != null ) {
        // Find an existing AVAILABLE session with non-negative priority.
        for (JID address : routingTable.getRoutes(recipient.asBareJID(), packet.getFrom())) {
            ClientSession session = routingTable.getClientRoute(address);
            if (session != null && session.isInitialized()) {
                if (session.getPresence().getPriority() >= 1) {
                    storeOffline = false;
                }
            }
        }
    }

    if ( !storeOffline )
    {
        // If message was sent to an unavailable full JID of a user then retry using the bare JID.
        routingTable.routePacket( recipient.asBareJID(), packet, false );
    }
    else
    {
        // Delegate to offline message strategy, which will either bounce or ignore the message depending on user settings.
        messageStrategy.storeOffline( (Message) packet );
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:37,代码来源:MessageRouter.java

示例3: run

import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
public void run() {
    if (getSession() == null || getSession().isClosed()) {
        logger.error("Session not found for JID: " + address);
        return;
    }
    super.run();

    ClientSession session = (ClientSession) getSession();
    if (session instanceof RemoteClientSession) {
        // The session is being hosted by other cluster node so log this unexpected case
        Cache<String, ClientRoute> usersCache = CacheFactory.createCache(RoutingTableImpl.C2S_CACHE_NAME);
        ClientRoute route = usersCache.get(address.toString());
        NodeID nodeID = route.getNodeID();

        logger.warn("Found remote session instead of local session. JID: " + address + " found in Node: " +
                nodeID.toByteArray() + " and local node is: " + XMPPServer.getInstance().getNodeID().toByteArray());
    }
    if (operation == Operation.isInitialized) {
        if (session instanceof RemoteClientSession) {
            // Something is wrong since the session shoud be local instead of remote
            // Assume some default value
            result = true;
        }
        else {
            result = session.isInitialized();
        }
    }
    else if (operation == Operation.incrementConflictCount) {
        if (session instanceof RemoteClientSession) {
            // Something is wrong since the session shoud be local instead of remote
            // Assume some default value
            result = 2;
        }
        else {
            result = session.incrementConflictCount();
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:39,代码来源:ClientSessionTask.java

示例4: run

import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
public void run() {
    super.run();

    ClientSession session = (ClientSession) getSession();
    if (session instanceof RemoteClientSession) {
        // The session is being hosted by other cluster node so log this unexpected case
        Cache<String, ClientRoute> usersCache = CacheFactory.createCache(RoutingTableImpl.C2S_CACHE_NAME);
        ClientRoute route = usersCache.get(address.toString());
        NodeID nodeID = route.getNodeID();

        Log.warn("Found remote session instead of local session. JID: " + address + " found in Node: " +
                nodeID.toByteArray() + " and local node is: " + XMPPServer.getInstance().getNodeID().toByteArray());
    }
    if (operation == Operation.isInitialized) {
        if (session instanceof RemoteClientSession) {
            // Something is wrong since the session shoud be local instead of remote
            // Assume some default value
            result = true;
        }
        else {
            result = session.isInitialized();
        }
    }
    else if (operation == Operation.incrementConflictCount) {
        if (session instanceof RemoteClientSession) {
            // Something is wrong since the session shoud be local instead of remote
            // Assume some default value
            result = 2;
        }
        else {
            result = session.incrementConflictCount();
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:35,代码来源:ClientSessionTask.java

示例5: run

import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
public void run() {
	if (getSession() == null || getSession().isClosed()) {
		logger.error("Session not found for JID: " + address);
		return;
	}
    super.run();

    ClientSession session = (ClientSession) getSession();
    if (session instanceof RemoteClientSession) {
        // The session is being hosted by other cluster node so log this unexpected case
        Cache<String, ClientRoute> usersCache = CacheFactory.createCache(RoutingTableImpl.C2S_CACHE_NAME);
        ClientRoute route = usersCache.get(address.toString());
        NodeID nodeID = route.getNodeID();

        logger.warn("Found remote session instead of local session. JID: " + address + " found in Node: " +
                nodeID.toByteArray() + " and local node is: " + XMPPServer.getInstance().getNodeID().toByteArray());
    }
    if (operation == Operation.isInitialized) {
        if (session instanceof RemoteClientSession) {
            // Something is wrong since the session shoud be local instead of remote
            // Assume some default value
            result = true;
        }
        else {
            result = session.isInitialized();
        }
    }
    else if (operation == Operation.incrementConflictCount) {
        if (session instanceof RemoteClientSession) {
            // Something is wrong since the session shoud be local instead of remote
            // Assume some default value
            result = 2;
        }
        else {
            result = session.incrementConflictCount();
        }
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:39,代码来源:ClientSessionTask.java

示例6: process

import org.jivesoftware.openfire.session.ClientSession; //导入方法依赖的package包/类
private void process(Presence presence, ClientSession session) throws UnauthorizedException, PacketException {
    try {
        Presence.Type type = presence.getType();
        // Available
        if (type == null) {
            if (session != null && session.getStatus() == Session.STATUS_CLOSED) {
                Log.warn("Rejected available presence: " + presence + " - " + session);
                return;
            }
            broadcastUpdate(presence.createCopy());
            if (session != null) {
                session.setPresence(presence);
                if (!session.isInitialized()) {
                    initSession(session);
                    session.setInitialized(true);
                }
            }
            // Notify the presence manager that the user is now available. The manager may
            // remove the last presence status sent by the user when he went offline.
            presenceManager.userAvailable(presence);
        }
        else if (Presence.Type.unavailable == type) {
            broadcastUpdate(presence.createCopy());
            broadcastUnavailableForDirectedPresences(presence);
            if (session != null) {
                session.setPresence(presence);
            }
            // Notify the presence manager that the user is now unavailable. The manager may
            // save the last presence status sent by the user and keep track when the user
            // went offline.
            presenceManager.userUnavailable(presence);
        }
        else {
            presence = presence.createCopy();
            if (session != null) {
                presence.setFrom(new JID(null, session.getServerName(), null, true));
                presence.setTo(session.getAddress());
            }
            else {
                JID sender = presence.getFrom();
                presence.setFrom(presence.getTo());
                presence.setTo(sender);
            }
            presence.setError(PacketError.Condition.bad_request);
            deliverer.deliver(presence);
        }

    }
    catch (Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error") + ". Triggered by packet: " + presence, e);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:53,代码来源:PresenceUpdateHandler.java


注:本文中的org.jivesoftware.openfire.session.ClientSession.isInitialized方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。