本文整理汇总了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;
}
示例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 );
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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();
}
}
}
示例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);
}
}