• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClientSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: sessionDestroyed

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
public void sessionDestroyed(Session session)
{
	Log.debug("OfMeet Plugin -  sessionDestroyed "+ session.getAddress().toString() + "\n" + ((ClientSession) session).getPresence().toXML());

	boolean skypeAvailable = XMPPServer.getInstance().getPluginManager().getPlugin("ofskype") != null;

	if (OfMeetAzure.skypeids.containsKey(session.getAddress().getNode()))
	{
		String sipuri = OfMeetAzure.skypeids.remove(session.getAddress().getNode());

		IQ iq = new IQ(IQ.Type.set);
		iq.setFrom(session.getAddress());
		iq.setTo(XMPPServer.getInstance().getServerInfo().getXMPPDomain());

		Element child = iq.setChildElement("request", "http://igniterealtime.org/protocol/ofskype");
		child.setText("{'action':'stop_skype_user', 'sipuri':'" + sipuri + "'}");
		XMPPServer.getInstance().getIQRouter().route(iq);

		Log.info("OfMeet Plugin - closing skype session " + sipuri);
	}
}
 
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:22,代码来源:OfMeetPlugin.java


示例2: 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


示例3: logout

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
/**
 * Disconnect an XMPP session of a user identified by an oauth token.
 * @param headers
 * @return
 */
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Path("logout")
public Response logout(@Context HttpHeaders headers) {
  TokenInfo tokenInfo = RestUtils.getAuthTokenInfo(headers);
  if (tokenInfo == null) {
    return RestUtils.getUnauthJAXRSResp();
  }
  
  JID from = RestUtils.createJID(tokenInfo);
  XMPPServer xmppSrv = XMPPServer.getInstance();
  SessionManager sessionMgr = xmppSrv.getSessionManager();
  ClientSession session = sessionMgr.getSession(from);
  if (session == null) {
    ErrorResponse response = new ErrorResponse(ErrorCode.USER_NOT_LOGIN,
        String.format("Session is not found: %s [%s]", from, tokenInfo.getUserName()));
    return RestUtils.getJAXRSResp(Response.Status.GONE, response);
  }
  // Terminate the session now.
  session.close();
  return RestUtils.getOKJAXRSResp();
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:28,代码来源:UserResource.java


示例4: execute

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
@Override
public void execute(SessionData data, Element command) {
    DataForm form = new DataForm(DataForm.Type.result);

    FormField field = form.addField();
    field.setType(FormField.Type.hidden);
    field.setVariable("FORM_TYPE");
    field.addValue("http://jabber.org/protocol/admin");

    field = form.addField();
    field.setLabel(getLabel());
    field.setVariable("onlineusersnum");
    // Make sure that we are only counting based on bareJIDs and not fullJIDs
    Collection<ClientSession> sessions = SessionManager.getInstance().getSessions();
    Set<String> users = new HashSet<>(sessions.size());
    for (ClientSession session : sessions) {
        users.add(session.getAddress().toBareJID());
    }
    field.addValue(users.size());

    command.add(form.getElement());
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:23,代码来源:GetNumberOnlineUsers.java


示例5: destroy

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
@Override
public void destroy()
{
    // terminate any active websocket sessions
    SessionManager sm = XMPPServer.getInstance().getSessionManager();
    for (ClientSession session : sm.getSessions()) {
        if (session instanceof LocalSession) {
            Object ws = ((LocalSession) session).getSessionData("ws");
            if (ws != null && (Boolean) ws) {
                session.close();
            }
        }
    }

    super.destroy();
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:OpenfireWebSocketServlet.java


示例6: getPresence

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
@Override
public Presence getPresence(User user) {
    if (user == null) {
        return null;
    }
    Presence presence = null;

    for (ClientSession session : sessionManager.getSessions(user.getUsername())) {
        if (presence == null) {
            presence = session.getPresence();
        }
        else {
            // Get the ordinals of the presences to compare. If no ordinal is available then
            // assume a value of -1
            int o1 = presence.getShow() != null ? presence.getShow().ordinal() : -1;
            int o2 = session.getPresence().getShow() != null ?
                    session.getPresence().getShow().ordinal() : -1;
            // Compare the presences' show ordinals
            if (o1 > o2) {
                presence = session.getPresence();
            }
        }
    }
    return presence;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:26,代码来源:PresenceManagerImpl.java


示例7: run

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
public void run() {
    ClientSession session = ((ClientSession) getSession());
    PrivacyList list = null;
    // Get the privacy list to set
    if (listName != null) {
        try {
            String username = session.getUsername();
            list = PrivacyListManager.getInstance().getPrivacyList(username, listName);
        } catch (UserNotFoundException e) {
            // Should never happen
        }
    }
    // Set the privacy list to the session
    if (activeList) {
        session.setActiveList(list);
    }
    else {
        session.setDefaultList(list);
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:21,代码来源:RemoteClientSession.java


示例8: setActiveList

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
/**
 * User has specified a new active list that should be used for the current session.
 *
 * @param packet IQ packet setting new active list for the current session.
 * @param from sender of the IQ packet.
 * @param listName name of the new active list for the current session.
 * @return acknowledge of success.
 */
private IQ setActiveList(IQ packet, JID from, String listName) {
    IQ result = IQ.createResultIQ(packet);
    Element childElement = packet.getChildElement().createCopy();
    result.setChildElement(childElement);

    // Get the list
    PrivacyList list = manager.getPrivacyList(from.getNode(), listName);
    if (list != null) {
        // Get the user session
        ClientSession session = sessionManager.getSession(from);
        if (session != null) {
            // Set the new active list for this session
            session.setActiveList(list);
        }
    }
    else {
        // List not found
        result.setError(PacketError.Condition.item_not_found);
    }
    return result;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:30,代码来源:IQPrivacyHandler.java


示例9: execute

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
@Override
public void execute(SessionData data, Element command) {
       DataForm form = new DataForm(DataForm.Type.result);

       FormField field = form.addField();
       field.setType(FormField.Type.hidden);
       field.setVariable("FORM_TYPE");
       field.addValue("http://jabber.org/protocol/admin");

       field = form.addField();
       field.setLabel(getLabel());
       field.setVariable("activeusersnum");
       // Make sure that we are only counting based on bareJIDs and not fullJIDs
       Collection<ClientSession> sessions = SessionManager.getInstance().getSessions();
       Set<String> users = new HashSet<String>(sessions.size());
       for (ClientSession session : sessions) {
           if (session.getPresence().isAvailable()) {
               users.add(session.getAddress().toBareJID());
           }
       }
       field.addValue(users.size());

       command.add(form.getElement());
   }
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:25,代码来源:GetNumberActiveUsers.java


示例10: declineDefaultList

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
/**
 * User has specified that there is no default list that should be used for this user.
 *
 * @param packet IQ packet declining default list for all sessions.
 * @param from sender of the IQ packet.
 * @return acknowledge of success.
 */
private IQ declineDefaultList(IQ packet, JID from) {
    IQ result = IQ.createResultIQ(packet);
    Element childElement = packet.getChildElement().createCopy();
    result.setChildElement(childElement);

    if (sessionManager.getSessionCount(from.getNode()) > 1) {
        // Current default list is being used by more than one session
        result.setError(PacketError.Condition.conflict);
    }
    else {
        // Get the user session
        ClientSession session = sessionManager.getSession(from);
        // Check if a default list was already defined
        if (session.getDefaultList() != null) {
            // Set the existing default list as non-default
            session.getDefaultList().setDefaultList(false);
            // Update the database with the new list state
            provider.updatePrivacyList(from.getNode(), session.getDefaultList());
            session.setDefaultList(null);
        }
    }
    return result;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:31,代码来源:IQPrivacyHandler.java


示例11: findUser

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
private JID findUser(String username)
   {
	Collection<ClientSession> sessions = SessionManager.getInstance().getSessions();
	JID foundUser = null;

	for (ClientSession session : sessions)
	{
		try{
			String userId = session.getAddress().getNode();

			if (username.equals(userId))
			{
				Log.info("Incoming SIP, findUser " + session.getAddress());

				foundUser = session.getAddress();
				break;
			}

		} catch (Exception e) { }
	}
	return foundUser;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:23,代码来源:RayoComponent.java


示例12: broadcastPresenceOfOtherResource

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
/**
 * Sends the presences of other connected resources to the resource that just connected.
 *
 * @param session the newly created session.
 */
private void broadcastPresenceOfOtherResource(LocalClientSession session) {
    if (!SessionManager.isOtherResourcePresenceEnabled()) {
        return;
    }
    Presence presence;
    // Get list of sessions of the same user
    JID searchJID = new JID(session.getAddress().getNode(), session.getAddress().getDomain(), null);
    List<JID> addresses = routingTable.getRoutes(searchJID, null);
    for (JID address : addresses) {
        if (address.equals(session.getAddress())) {
            continue;
        }
        // Send the presence of an existing session to the session that has just changed
        // the presence
        ClientSession userSession = routingTable.getClientRoute(address);
        presence = userSession.getPresence().createCopy();
        presence.setTo(session.getAddress());
        session.process(presence);
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:26,代码来源:SessionManager.java


示例13: sessionDisconnected

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
/**
 * Should be called when a session has been disconnected.
 *
 * This can be anything from a standard logout to a forced disconnect from the server.
 *
 * @param errorMessage Error message to send, or null if no message.  (only sent on full disconnect)
 */
public void sessionDisconnected(String errorMessage) {
    reconnectionAttempts++;
    if (getRegistrationPacket() != null || !JiveGlobals.getBooleanProperty("plugin.gateway."+getTransport().getType()+"reconnect", true) || (reconnectionAttempts > JiveGlobals.getIntProperty("plugin.gateway."+getTransport().getType()+"reconnectattempts", 3))) {
        sessionDisconnectedNoReconnect(errorMessage);
    }
    else {
        cleanUp();
        Log.debug("Session "+getJID()+" disconnected from "+getTransport().getJID()+".  Reconnecting... (attempt "+reconnectionAttempts+")");
        setLoginStatus(TransportLoginStatus.RECONNECTING);
        ClientSession session = XMPPServer.getInstance().getSessionManager().getSession(getJIDWithHighestPriority());
        if (session != null) {
            logIn(getTransport().getPresenceType(session.getPresence()), null);
        }
        else {
            sessionDisconnectedNoReconnect(errorMessage);
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:26,代码来源:TransportSession.java


示例14: start

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
/**
 * Handles startup of the transport.
 */
public void start() {
    RosterEventDispatcher.addListener(this);
    UserEventDispatcher.addListener(this);
    SessionEventDispatcher.addListener(this);
    VCardEventDispatcher.addListener(this);
    InterceptorManager.getInstance().addInterceptor(this);
    if (!JiveGlobals.getBooleanProperty("plugin.gateway.tweak.noprobeonstart", false)) {
        // Probe all registered users [if they are logged in] to auto-log them in
        // TODO: Do we need to account for local vs other node sessions?
        for (ClientSession session : SessionManager.getInstance().getSessions()) {
            try {
                JID jid = XMPPServer.getInstance().createJID(session.getUsername(), null);
                if (RegistrationManager.getInstance().isRegistered(jid, getType())) {
                    Presence p = new Presence(Presence.Type.probe);
                    p.setFrom(this.getJID());
                    p.setTo(jid);
                    sendPacket(p);
                }
            }
            catch (UserNotFoundException e) {
                // Not a valid user for the gateway then
            }
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:29,代码来源:BaseTransport.java


示例15: findUser

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
private JID findUser(String username)
{
    Collection<ClientSession> sessions = SessionManager.getInstance().getSessions();
    JID foundUser = null;

    for (ClientSession session : sessions)
    {
        try{
            String userId = session.getAddress().getNode();

            if (username.equals(userId))
            {
                Log.info("Incoming SIP, findUser " + session.getAddress());

                foundUser = session.getAddress();
                break;
            }

        } catch (Exception e) { }
    }
    return foundUser;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:23,代码来源:RayoComponent.java


示例16: broadcastPresenceOfOtherResource

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
/**
 * Sends the presences of other connected resources to the resource that just connected.
 * 
 * @param session the newly created session.
 */
private void broadcastPresenceOfOtherResource(LocalClientSession session) {
    Presence presence;
    // Get list of sessions of the same user
    JID searchJID = new JID(session.getAddress().getNode(), session.getAddress().getDomain(), null);
    List<JID> addresses = routingTable.getRoutes(searchJID, null);
    for (JID address : addresses) {
        if (address.equals(session.getAddress())) {
            continue;
        }
        // Send the presence of an existing session to the session that has just changed
        // the presence
        ClientSession userSession = routingTable.getClientRoute(address);
        presence = userSession.getPresence().createCopy();
        presence.setTo(session.getAddress());
        session.process(presence);
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:23,代码来源:SessionManager.java


示例17: getSession

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
/**
 * Returns the session responsible for this JID data. The returned Session may have never sent
 * an available presence (thus not have a route) or could be a Session that hasn't
 * authenticated yet (i.e. preAuthenticatedSessions).
 *
 * @param from the sender of the packet.
 * @return the <code>Session</code> associated with the JID.
 */
public ClientSession getSession(JID from) {
    // Return null if the JID is null or belongs to a foreign server. If the server is
    // shutting down then serverName will be null so answer null too in this case.
    if (from == null || serverName == null || !serverName.equals(from.getDomain())) {
        return null;
    }

    // Initially Check preAuthenticated Sessions
    if (from.getResource() != null) {
        ClientSession session = localSessionManager.getPreAuthenticatedSessions().get(from.getResource());
        if (session != null) {
            return session;
        }
    }

    if (from.getResource() == null || from.getNode() == null) {
        return null;
    }

    return routingTable.getClientRoute(from);
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:30,代码来源:SessionManager.java


示例18: execute

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
@Override
public void execute(SessionData data, Element command) {
       DataForm form = new DataForm(DataForm.Type.result);

       FormField field = form.addField();
       field.setType(FormField.Type.hidden);
       field.setVariable("FORM_TYPE");
       field.addValue("http://jabber.org/protocol/admin");

       field = form.addField();
       field.setLabel(getLabel());
       field.setVariable("onlineusersnum");
       // Make sure that we are only counting based on bareJIDs and not fullJIDs
       Collection<ClientSession> sessions = SessionManager.getInstance().getSessions();
       Set<String> users = new HashSet<String>(sessions.size());
       for (ClientSession session : sessions) {
           users.add(session.getAddress().toBareJID());
       }
       field.addValue(users.size());

       command.add(form.getElement());
   }
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:23,代码来源:GetNumberOnlineUsers.java


示例19: terminateSessions

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
/**
 * Terminate open session for the user with specified user name. Username should be complete ie it should
 * include the % appid.
 * @param username
 */
public static void terminateSessions(String username) throws ServerNotInitializedException {
  final StreamError error = new StreamError(StreamError.Condition.not_authorized);
  for (ClientSession session : getSessionManager().getSessions(username) ) {
    LOGGER.info("Terminating session for user with name:{}", username);
    session.deliverRawText(error.toXML());
    session.close();
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:14,代码来源:UserManagerService.java


示例20: execute

import org.jivesoftware.openfire.session.ClientSession; //导入依赖的package包/类
@Override
public void execute(SessionData data, Element command) {
    String max_items = data.getData().get("max_items").get(0);
    int maxItems = -1;
    if (max_items != null && !"none".equals(max_items)) {
        try {
            maxItems = Integer.parseInt(max_items);
        }
        catch (NumberFormatException e) {
            // Do nothing. Assume that all users are being requested
        }
    }

    DataForm form = new DataForm(DataForm.Type.result);

    FormField field = form.addField();
    field.setType(FormField.Type.hidden);
    field.setVariable("FORM_TYPE");
    field.addValue("http://jabber.org/protocol/admin");

    field = form.addField();
    field.setLabel("The presences of active users");
    field.setVariable("activeuserpresences");

    // Get list of users (i.e. bareJIDs) that are connected to the server
    Collection<ClientSession> sessions = SessionManager.getInstance().getSessions();
    int index = 1;
    for (ClientSession session : sessions) {
        if (session.getPresence().isAvailable()) {
            field.addValue(session.getPresence().toXML());
        }
        if (maxItems > 0 && index >= maxItems) {
            break;
        }
    }
    command.add(form.getElement());
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:38,代码来源:GetUsersPresence.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MultiTimeUseOrTimeoutExpirationPolicy类代码示例发布时间:2022-05-22
下一篇:
Java QueryObjectModelFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap