本文整理汇总了Java中rocks.xmpp.core.session.XmppSession类的典型用法代码示例。如果您正苦于以下问题:Java XmppSession类的具体用法?Java XmppSession怎么用?Java XmppSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmppSession类属于rocks.xmpp.core.session包,在下文中一共展示了XmppSession类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findFirstMucDomain
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
/**
* Returns the domain of the first XMPP MUC service available
*
* @return The first found MUC domain if any, else null
*/
private String findFirstMucDomain() {
try {
// Get the MUC extension manager
final XmppSession session = pBot.getSession();
final MultiUserChatManager mucManager = session
.getExtensionManager(MultiUserChatManager.class);
// Get the list of chat services
final Collection<ChatService> chatServices = mucManager
.getChatServices();
// Use the first one available (same as Python side)
return chatServices.iterator().next().getAddress().getDomain();
} catch (final XmppException ex) {
pLogger.log(LogService.LOG_ERROR,
"Error looking for XMPP MUC chat services: " + ex);
}
return null;
}
示例2: onSessionStart
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
@Override
public void onSessionStart(final XmppSession aSession) {
// Log our JID
pLogger.log(LogService.LOG_INFO, "Bot connected with JID: "
+ pBot.getJid().asBareJid());
// Get local peer information
final Peer localPeer = pDirectory.getLocalPeer();
final String appId = localPeer.getApplicationId();
// Create/join rooms for each group
final Set<String> allRooms = new LinkedHashSet<>();
for (final String group : localPeer.getGroups()) {
allRooms.add(appId + "--" + group);
}
allRooms.add(appId);
// Wait to have joined all rooms before activating the service
pLogger.log(LogService.LOG_DEBUG, "Creating XMPP rooms...");
createRooms(allRooms, localPeer.getUid());
}
示例3: onSessionEnd
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
@Override
public void onSessionEnd(final XmppSession aSession) {
// Clean up our access
pDirectory.getLocalPeer().unsetAccess(IXmppConstants.ACCESS_ID);
// Shut down the service
pController = false;
}
示例4: RoomCreator
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
public RoomCreator(final XmppSession aSession, final LogService aLogger) {
// Setup members
pLogger = aLogger;
pSession = aSession;
// Find the MUC chat service
findChatServices();
}
示例5: isConnected
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
/**
* Returns true if connection online and authenticated.
*
* @return true or false.
*/
public boolean isConnected() {
if (getXmppSession() != null && getXmppSession().getStatus() == XmppSession.Status.AUTHENTICATED) {
return true;
}
return false;
}
示例6: ManageVoiceMessageHandler
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
public ManageVoiceMessageHandler(XmppSession xmppSession) {
this.xmppSession = xmppSession;
}
示例7: PrivateDataHandler
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
public PrivateDataHandler(XmppSession xmppSession) {
this.xmppSession = xmppSession;
this.privateDataManager = this.xmppSession.getExtensionManager(PrivateDataManager.class);
}
示例8: getXmppSession
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
/**
* Get XMPP (Babbler) connection object.
*/
public XmppSession getXmppSession() {
return xmppSession;
}
示例9: setXmppSession
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
private void setXmppSession(XmppSession xmppSession) {
this.xmppSession = xmppSession;
}
示例10: activate
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
public void activate(final Router router) throws XmppException, InterruptedException, SuspendExecution {
// connect to xmpp
XmppSessionConfiguration configuration = XmppSessionConfiguration.builder().build();
xmppSession = new XmppSession("chat.hipchat.com", configuration);
xmppSession.connect();
xmppSession.login(username, password);
xmppSession.send(new Presence());
// join the rooms
joinRooms(this.rooms);
// send a welcome message
joinedRooms.values().stream()
.forEach(cr -> {
String peeps = String.join(", ", cr.getOccupants().stream()
.filter(x -> !x.isSelf())
.map(Occupant::getNick)
.collect(Collectors.toList()));
cr.sendMessage("Hey " + peeps);
});
log.info("Joined room(s) " + String.join(", ", joinedRooms.keySet()));
// reconnect listener
xmppSession.addSessionStatusListener(e -> {
if (e.getStatus() == XmppSession.Status.AUTHENTICATED) {
try {
joinRooms(this.rooms);
} catch (XmppException e1) {
e1.printStackTrace();
}
} else {
log.info("Received unhandled session status: " + e.getStatus());
}
});
selectMessageLoop(router);
}
示例11: getSession
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
/**
* Returns the internal Babbler {@link XmppSession}
*
* @return The XMPP session
*/
public XmppSession getSession() {
return pSession;
}
示例12: onSessionEnd
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
/**
* The XMPP session has ended
*
* @param aSession
* The XMPP session
*/
void onSessionEnd(XmppSession aSession);
示例13: onSessionStart
import rocks.xmpp.core.session.XmppSession; //导入依赖的package包/类
/**
* The XMPP session has started, client is authenticated
*
* @param aSession
* The XMPP session
*/
void onSessionStart(XmppSession aSession);