當前位置: 首頁>>代碼示例>>Java>>正文


Java XMPPTCPConnection.isAuthenticated方法代碼示例

本文整理匯總了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();
		});
	}
 
開發者ID:Flowdalic,項目名稱:android-xmpp-iot-demo,代碼行數:37,代碼來源:ClaimThingActivity.java

示例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);


    }
 
開發者ID:saveendhiman,項目名稱:XMPPSample_Studio,代碼行數:40,代碼來源:XMPP.java

示例3: isConnectionUseable

import org.jivesoftware.smack.tcp.XMPPTCPConnection; //導入方法依賴的package包/類
boolean isConnectionUseable() {
	final XMPPTCPConnection connection = xmppConnection;
	return connection != null && connection.isAuthenticated();
}
 
開發者ID:Flowdalic,項目名稱:android-xmpp-iot-demo,代碼行數:5,代碼來源:XmppManager.java

示例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();
                }

            }
        }
    }
 
開發者ID:esl,項目名稱:mangosta-android,代碼行數:55,代碼來源:RoomManager.java


注:本文中的org.jivesoftware.smack.tcp.XMPPTCPConnection.isAuthenticated方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。