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


Java XMPPException.printStackTrace方法代碼示例

本文整理匯總了Java中org.jivesoftware.smack.XMPPException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java XMPPException.printStackTrace方法的具體用法?Java XMPPException.printStackTrace怎麽用?Java XMPPException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jivesoftware.smack.XMPPException的用法示例。


在下文中一共展示了XMPPException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getHostRooms

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * 獲取用戶的所有聊天室
 * @param xmppConnection
 * @return
 */
public static List<HostedRoom>  getHostRooms(XMPPConnection xmppConnection){
    List<HostedRoom> roominfos = new ArrayList<HostedRoom>();
    try {
        new ServiceDiscoveryManager(xmppConnection);
        Collection<HostedRoom> hostrooms = MultiUserChat.getHostedRooms(xmppConnection,xmppConnection.getServiceName());
        for (HostedRoom entry : hostrooms) {
            roominfos.add(entry);
            Log.i("room", "名字:" + entry.getName() + " - ID:" + entry.getJid());
        }
        Log.i("room", "服務會議數量:" + roominfos.size());
    } catch (XMPPException e) {
        Log.e("getHostRooms",e.getMessage());
        e.printStackTrace();
    }
    return roominfos;
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:22,代碼來源:XMPPUtil.java

示例2: getRoomByJID

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
public synchronized JabberRoom getRoomByJID(JabberClient client, String jid, String defaultName) {
  if (jid == null) {
    return null;
  }
  JabberRoom newRoom = jidToRoom.get(jid);
  if (newRoom == null) {
    String roomName = defaultName == null ? "" : defaultName; //$NON-NLS-1$
    RoomInfo info = null;
    try {
      info = MultiUserChat.getRoomInfo(client.getConnection(), jid);
    }
    // FIXME: review error message
    catch (XMPPException e) {
      e.printStackTrace();
    }
    newRoom = new JabberRoom(roomName, jid, info, client);
    jidToRoom.put(jid, newRoom);
  }
  return newRoom;
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:21,代碼來源:JabberRoom.java

示例3: regist

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * 注冊用戶
 * @param xmppConnection
 * @param userName
 * @param password
 * @param attributes
 * @return
 */
public static boolean regist(XMPPConnection xmppConnection,String userName,String password,Map<String,String> attributes){
	AccountManager accountManager=xmppConnection.getAccountManager();
	try {
		if(attributes!=null){
			accountManager.createAccount(userName, password, attributes);
		}
		else{
			accountManager.createAccount(userName, password);
		}
		return true;
	} catch (XMPPException e) {
		e.printStackTrace();
		return false;
	}
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:24,代碼來源:XMPPUtil.java

示例4: login

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * 登錄
 * @param userName
 * @param password
 * @return
 */
public static XMPPConnection login(String userName,String password){
	XMPPConnection xmppConnection = createXMPPConnection();
	if (xmppConnection != null) {
		try {
			if (!xmppConnection.isConnected()) {
				xmppConnection.connect();
			}
			xmppConnection.login(userName, password);
		} catch (XMPPException e) {
			e.printStackTrace();
			xmppConnection = null;
		}
	}
	return xmppConnection;
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:22,代碼來源:XMPPUtil.java

示例5: searchUsers

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * 查詢用戶
 * @param xmppConnection
 * @param userName
 * @return
 * @throws XMPPException
 */
public static List<HashMap<String, String>> searchUsers(XMPPConnection xmppConnection,String userName) {
    List<HashMap<String, String>> results = new ArrayList<HashMap<String, String>>();
    try {
        UserSearchManager usm = new UserSearchManager(xmppConnection);
        Form searchForm = usm.getSearchForm(xmppConnection.getServiceName());
        Form answerForm = searchForm.createAnswerForm();
        answerForm.setAnswer("userAccount", true);
        answerForm.setAnswer("userPhote", userName);
        ReportedData data = usm.getSearchResults(answerForm, "search" + xmppConnection.getServiceName());
        Iterator<ReportedData.Row> it = data.getRows();
        while (it.hasNext()) {
        	HashMap<String, String> user = new HashMap<String, String>();
            ReportedData.Row row = it.next();
            user.put("userAccount", row.getValues("userAccount").next().toString());
            user.put("userPhote", row.getValues("userPhote").next().toString());
            results.add(user);
        }
    } catch (XMPPException e) {
        e.printStackTrace();
    }
    return results;
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:30,代碼來源:XMPPUtil.java

示例6: joinMultiUserChat

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * 加入聊天室
 * @param xmppConnection
 * @param roomName
 * @param password
 * @return
 */
public static  MultiUserChat joinMultiUserChat(XMPPConnection xmppConnection,String roomName,String password,PacketListener packetListener){
    try {
        // 使用XMPPConnection創建一個MultiUserChat窗口
        MultiUserChat muc = new MultiUserChat(xmppConnection, roomName+ "@conference." + xmppConnection.getServiceName());
        // 聊天室服務將會決定要接受的曆史記錄數量
        DiscussionHistory history = new DiscussionHistory();
        history.setMaxChars(0);
        // 用戶加入聊天室
        muc.join(xmppConnection.getUser(), password, history, SmackConfiguration.getPacketReplyTimeout());
        if(packetListener!=null){
        	muc.addMessageListener(packetListener);
        }
        return muc;
    } catch (XMPPException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:26,代碼來源:XMPPUtil.java

示例7: regist

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * 注冊用戶
 * @param xmppConnection
 * @param userName
 * @param password
 * @param attributes
 * @return
 */
public static boolean regist(XMPPConnection xmppConnection, String userName, String password, Map<String, String> attributes) {
    AccountManager accountManager = xmppConnection.getAccountManager();
    try {
        if (attributes != null) {
            accountManager.createAccount(userName, password, attributes);
        } else {
            accountManager.createAccount(userName, password);
        }
        return true;
    } catch (XMPPException e) {
        Log.e("regist", e.getMessage());
        e.printStackTrace();
        return false;
    }
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:24,代碼來源:XMPPUtil.java

示例8: searchUsers

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * 查詢用戶
 * @param xmppConnection
 * @param userName
 * @return
 * @throws XMPPException
 */
public static List<HashMap<String, String>> searchUsers(XMPPConnection xmppConnection, String userName) {
    List<HashMap<String, String>> results = new ArrayList<HashMap<String, String>>();
    try {
        UserSearchManager usm = new UserSearchManager(xmppConnection);
        Form searchForm = usm.getSearchForm(xmppConnection.getServiceName());
        Form answerForm = searchForm.createAnswerForm();
        answerForm.setAnswer("userAccount", true);
        answerForm.setAnswer("userPhote", userName);
        ReportedData data = usm.getSearchResults(answerForm, "search" + xmppConnection.getServiceName());
        Iterator<ReportedData.Row> it = data.getRows();
        while (it.hasNext()) {
            HashMap<String, String> user = new HashMap<String, String>();
            ReportedData.Row row = it.next();
            user.put("userAccount", row.getValues("userAccount").next().toString());
            user.put("userPhote", row.getValues("userPhote").next().toString());
            results.add(user);
        }
    } catch (XMPPException e) {
        Log.e("searchUsers", e.getMessage());
        e.printStackTrace();
    }
    return results;
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:31,代碼來源:XMPPUtil.java

示例9: login

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * ��¼
 * 
 * @param user
 * @param password
 */
public static void login(String user, String password) {

	if (connection == null) {
		init();
	}
	try {
		/** �û���½���û��������� */
		connection.login(user, password);
	} catch (XMPPException e) {
		e.printStackTrace();
	}
	/** ��ȡ��ǰ��½�û� */
	fail("User:", connection.getUser());
	addGroup(connection.getRoster(), "�ҵĺ���");
	addGroup(connection.getRoster(), "������");
	System.out.println("OK");

}
 
開發者ID:jiangzehui,項目名稱:xmpp,代碼行數:25,代碼來源:XmppTool.java

示例10: connectToServer

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * 建立與服務器的持久連接 (必須僅能被getConnection()直接調用)
 *
 * @return boolean  成功。如成功連接服務器返回true,否則false
 */
private boolean connectToServer() {
    if (connection == null || !connection.isConnected()) {
        try {


            //配置連接
            XMPPConnection.DEBUG_ENABLED = true;
            ConnectionConfiguration config =
                    new ConnectionConfiguration(HOST, PORT, GROUP);
            config.setReconnectionAllowed(true);
            config.setSendPresence(false);

            //創建並連接
            connection = new XMPPConnection(config);
            connection.connect();
            if(!connection.isConnected())
                throw new XMPPException();
            return connection.isConnected();
        } catch (XMPPException e) {
            e.printStackTrace();
            connection = null;
        }
    }
    return false;
}
 
開發者ID:lfkdsk,項目名稱:PracticeCode,代碼行數:31,代碼來源:XSCHelper.java

示例11: setUserBasicData

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * 設置基礎信息
 *
 * @param password 可null。非空則更改登錄密碼為password
 * @param nickName 可null。非空則更改昵稱為nickName
 */
public void setUserBasicData(String password, String nickName) {
    try {
        if(getConnection() == null || !getConnection().isAuthenticated())
            return;

        if (password != null) {
            getConnection().getAccountManager().changePassword(password);
        }

        VCard card = getVCard();
        if(nickName != null && card != null){
            card.setNickName(nickName);
            card.save(getConnection());
        }
    } catch (XMPPException e) {
        e.printStackTrace();
    }
}
 
開發者ID:lfkdsk,項目名稱:PracticeCode,代碼行數:25,代碼來源:XSCHelper.java

示例12: setUserEnhancedData

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * 設置進階信息
 *
 * @param map 以String為鍵、String為值存儲的鍵值對
 */
public void setUserEnhancedData(LinkedHashMap<String, String> map) {
    //如果沒有網絡連接直接返回
    if(getConnection() == null)
        return;

    try {
        VCard card = getVCard();
        if (card != null) {
            for(Map.Entry<String, String> en : map.entrySet())
                card.setField(en.getKey(), en.getValue());
            card.save(getConnection());
        }
    } catch (XMPPException e) {
        e.printStackTrace();
    }
}
 
開發者ID:lfkdsk,項目名稱:PracticeCode,代碼行數:22,代碼來源:XSCHelper.java

示例13: testCreateInstantRoom

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
/**
 * Tests creating a new "Instant Room".
 */
public void testCreateInstantRoom() {
    MultiUserChat muc = new MultiUserChat(getConnection(0), room);

    try {
        // Create the room
        muc.create("testbot");

        // Send an empty room configuration form which indicates that we want
        // an instant room
        muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));

        // Destroy the new room
        muc.destroy("The room has almost no activity...", null);
    }
    catch (XMPPException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:23,代碼來源:MultiUserChatCreationTest.java

示例14: testDiscoverJoinedRooms

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
public void testDiscoverJoinedRooms() {
    try {
        // Check that user1 has joined only to one room
        Iterator<String> joinedRooms = MultiUserChat.getJoinedRooms(getConnection(1), getFullJID(0));
        assertTrue("Joined rooms shouldn't be empty", joinedRooms.hasNext());
        assertEquals("Joined room is incorrect", joinedRooms.next(), room);
        assertFalse("User has joined more than one room", joinedRooms.hasNext());

        // Leave the new room
        muc.leave();

        // Check that user1 is not currently join any room
        joinedRooms = MultiUserChat.getJoinedRooms(getConnection(1), getFullJID(0));
        assertFalse("Joined rooms should be empty", joinedRooms.hasNext());

        muc.join("testbot");
    }
    catch (XMPPException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:23,代碼來源:MultiUserChatTest.java

示例15: testDiscoverRoomInfo

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
public void testDiscoverRoomInfo() {
    try {
        makeRoomModerated();

        RoomInfo info = MultiUserChat.getRoomInfo(getConnection(1), room);

        assertFalse("Room is members-only", info.isMembersOnly());
        assertTrue("Room is moderated", info.isModerated());
        assertFalse("Room is Nonanonymous", info.isNonanonymous());
        assertFalse("Room is PasswordProtected", info.isPasswordProtected());
        assertFalse("Room is Persistent", info.isPersistent());
        assertEquals("Room's description is incorrect", "fruta124", info.getDescription());
        assertEquals("Room's subject is incorrect", "", info.getSubject());
        assertEquals("Number of occupants is incorrect", 1, info.getOccupantsCount());
    }
    catch (XMPPException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:21,代碼來源:MultiUserChatTest.java


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