本文整理汇总了Java中org.jivesoftware.smack.tcp.XMPPTCPConnection.isAuthenticated方法的典型用法代码示例。如果您正苦于以下问题:Java XMPPTCPConnection.isAuthenticated方法的具体用法?Java XMPPTCPConnection.isAuthenticated怎么用?Java XMPPTCPConnection.isAuthenticated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.tcp.XMPPTCPConnection
的用法示例。
在下文中一共展示了XMPPTCPConnection.isAuthenticated方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: claimButtonClicked
import org.jivesoftware.smack.tcp.XMPPTCPConnection; //导入方法依赖的package包/类
private void claimButtonClicked(final Thing thing) {
final XMPPTCPConnection connection = mXmppManger.getXmppConnection();
if (connection == null) {
showInGui("Not connection available");
return;
}
if (!connection.isAuthenticated()) {
showInGui("Connection not authenticated");
return;
}
IoTDiscoveryManager ioTDiscoveryManager = IoTDiscoveryManager.getInstanceFor(connection);
IoTClaimed iotClaimed;
try {
iotClaimed = ioTDiscoveryManager.claimThing(mRegistry, thing.getMetaTags(), true);
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException e) {
showInGui("Could not claim because " + e);
LOGGER.log(Level.WARNING, "Could not register", e);
return;
}
EntityBareJid claimedJid = iotClaimed.getJid().asEntityBareJidIfPossible();
if (claimedJid == null) {
throw new IllegalStateException();
}
Settings settings = Settings.getInstance(this);
settings.setClaimedJid(claimedJid);
showInGui("Thing " + claimedJid + " claimed.");
runOnUiThread(() -> {
finish();
});
}
示例2: login
import org.jivesoftware.smack.tcp.XMPPTCPConnection; //导入方法依赖的package包/类
public void login(String user, String pass, StatusItem status, String username)
throws XMPPException, SmackException, IOException, InterruptedException {
Log.i(TAG, "inside XMPP getlogin Method");
long l = System.currentTimeMillis();
XMPPTCPConnection connect = connect();
if (connect.isAuthenticated()) {
Log.i(TAG, "User already logged in");
return;
}
Log.i(TAG, "Time taken to connect: " + (System.currentTimeMillis() - l));
l = System.currentTimeMillis();
connect.login(user, pass);
Log.i(TAG, "Time taken to login: " + (System.currentTimeMillis() - l));
Log.i(TAG, "login step passed");
Presence p = new Presence(Presence.Type.available);
p.setMode(Presence.Mode.available);
p.setPriority(24);
p.setFrom(connect.getUser());
if (status != null) {
p.setStatus(status.toJSON());
} else {
p.setStatus(new StatusItem().toJSON());
}
// p.setTo("");
VCard ownVCard = new VCard();
ownVCard.load(connect);
ownVCard.setNickName(username);
ownVCard.save(connect);
PingManager pingManager = PingManager.getInstanceFor(connect);
pingManager.setPingInterval(150000);
connect.sendPacket(p);
}
示例3: isConnectionUseable
import org.jivesoftware.smack.tcp.XMPPTCPConnection; //导入方法依赖的package包/类
boolean isConnectionUseable() {
final XMPPTCPConnection connection = xmppConnection;
return connection != null && connection.isAuthenticated();
}
示例4: loadMUCLightRooms
import org.jivesoftware.smack.tcp.XMPPTCPConnection; //导入方法依赖的package包/类
public void loadMUCLightRooms() {
final XMPPTCPConnection connection = XMPPSession.getInstance().getXMPPConnection();
if (connection.isAuthenticated()) {
DiscoverItems discoverItems = XMPPSession.getInstance().discoverMUCLightItems();
if (discoverItems != null) {
RealmManager.getInstance().hideAllMUCLightChats();
List<DiscoverItems.Item> items = discoverItems.getItems();
Realm realm = RealmManager.getInstance().getRealm();
try {
for (DiscoverItems.Item item : items) {
String itemJid = item.getEntityID().toString();
if (itemJid.contains(XMPPSession.MUC_LIGHT_SERVICE_NAME)) {
Chat chatRoom = realm.where(Chat.class).equalTo("jid", itemJid).findFirst();
if (chatRoom == null) {
chatRoom = new Chat();
chatRoom.setJid(item.getEntityID().toString());
chatRoom.setType(Chat.TYPE_MUC_LIGHT);
getSubject(chatRoom);
}
realm.beginTransaction();
chatRoom.setShow(true);
chatRoom.setName(item.getName());
realm.copyToRealmOrUpdate(chatRoom);
realm.commitTransaction();
// set last retrieved from MAM
ChatMessage chatMessage = RealmManager.getInstance().getFirstMessageForChat(chatRoom.getJid());
if (chatMessage != null) {
realm.beginTransaction();
chatRoom.setLastRetrievedFromMAM(chatMessage.getMessageId());
realm.copyToRealmOrUpdate(chatRoom);
realm.commitTransaction();
}
}
}
} finally {
realm.close();
mListener.onRoomsLoaded();
}
}
}
}