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


Java XMPPException類代碼示例

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


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

示例1: init

import org.jivesoftware.smack.XMPPException; //導入依賴的package包/類
public void init() throws XMPPException {
  new TrackRooms().addTo(conn);
  new TrackStatus(getMonitorRoomJID().toLowerCase()).addTo(conn);
  new ListenForChat().addTo(conn);
  monitorRoom = new MultiUserChat(conn, getMonitorRoomJID());
  monitorRoom.addMessageListener(this);
  monitorRoom.addParticipantStatusListener(this);
  monitorRoom.join(StringUtils.parseName(conn.getUser()));
  try {
    // This is necessary to create the room if it doesn't already exist
    monitorRoom.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
  }
  catch (XMPPException ex) {
    // 403 code means the room already exists and user is not an owner
    if (ex.getXMPPError().getCode() != 403) {
      throw ex;
    }
  }
  sendStatus(me);
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:21,代碼來源:JabberClient.java

示例2: process

import org.jivesoftware.smack.XMPPException; //導入依賴的package包/類
public void process(Packet packet) {
  if (roomResponseFilter.accept(packet)) {
    final DiscoverItems result = (DiscoverItems) packet;
    final JabberPlayer player = playerMgr.getPlayer(packet.getFrom());
    // Collect the entityID for each returned item
    for (Iterator<DiscoverItems.Item> items = result.getItems(); items.hasNext();) {
      final String roomJID = items.next().getEntityID();
      final JabberRoom room = roomMgr.getRoomByJID(JabberClient.this, roomJID);
      try {
       room.setInfo(MultiUserChat.getRoomInfo(JabberClient.this
            .getConnection(), roomJID));
      }
      catch (XMPPException e) {
        // Ignore Error
      }
      if (!roomJID.equals(monitorRoom.getRoom())) {
        player.join(roomMgr.getRoomByJID(JabberClient.this, roomJID));
      }
    }
    fireRoomsUpdated();
  }
  else if (newPlayerFilter.accept(packet)) {
    sendRoomQuery(getAbsolutePlayerJID(packet.getFrom()));
  }
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:26,代碼來源:JabberClient.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: joinMultiUserChat

import org.jivesoftware.smack.XMPPException; //導入依賴的package包/類
/**
 * 加入聊天室
 * @param xmppConnection
 * @param roomName
 * @param password
 * @param packetListener 消息監聽器
 * @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);
        // history.setSince(new Date());
        // 用戶加入聊天室
        muc.join(xmppConnection.getUser(), password, history, SmackConfiguration.getPacketReplyTimeout());
        Log.i("MultiUserChat", "會議室【"+roomName+"】加入成功........");
        if(packetListener!=null){
            muc.addMessageListener(packetListener);
        }
        return muc;
    } catch (XMPPException e) {
        Log.e("MultiUserChat", "會議室【"+roomName+"】加入失敗........");
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:30,代碼來源:XMPPUtil.java

示例12: 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

示例13: login

import org.jivesoftware.smack.XMPPException; //導入依賴的package包/類
/**
 * 登錄
 *
 * @param name
 * @param pwd
 * @return
 */
public boolean login(String name, String pwd, Context context) {

    try {
        this.context = context;
        // SASLAuthentication.supportSASLMechanism("PLAIN", 0);
        con.login(name.toLowerCase(), pwd);
        // getMessage();//獲取離線消息
        int status = SharedPreferencesUtil.getInt(context, "status", name + "status");
        setPresence(status);//設置狀態,默認為在線狀態
        return true;
    } catch (XMPPException e) {
        SLog.e(tag, Log.getStackTraceString(e));
    }
    return false;
}
 
開發者ID:jiangzehui,項目名稱:xmpp,代碼行數:23,代碼來源:XmppTool.java

示例14: testPurgeItems

import org.jivesoftware.smack.XMPPException; //導入依賴的package包/類
public void testPurgeItems() throws XMPPException
{
	LeafNode node = getRandomPubnode(getManager(), true, false);
	
	node.send(new Item());
	node.send(new Item());
	node.send(new Item());
	node.send(new Item());
	node.send(new Item());
	
	Collection<? extends Item> items = node.getItems();
	assertTrue(items.size() == 5);

	node.deleteAllItems();
	items = node.getItems();
	
	// Pubsub service may keep the last notification (in spec), so 0 or 1 may be returned on get items.
	assertTrue(items.size() < 2);
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:20,代碼來源:OwnerUseCases.java

示例15: searchUsers

import org.jivesoftware.smack.XMPPException; //導入依賴的package包/類
/**
 * 查找用戶
 *
 * @param
 * @param userName
 * @return
 */
public List<XmppUser> searchUsers(String userName) {
    List<XmppUser> list = new ArrayList<XmppUser>();
    UserSearchManager userSearchManager = new UserSearchManager(con);
    try {
        Form searchForm = userSearchManager.getSearchForm("search."
                + con.getServiceName());
        Form answerForm = searchForm.createAnswerForm();
        answerForm.setAnswer("Username", true);
        answerForm.setAnswer("Name", true);
        answerForm.setAnswer("search", userName);
        ReportedData data = userSearchManager.getSearchResults(answerForm,
                "search." + con.getServiceName());
        Iterator<ReportedData.Row> rows = data.getRows();
        while (rows.hasNext()) {
            XmppUser user = new XmppUser(null, null);
            ReportedData.Row row = rows.next();
            user.setUserName(row.getValues("Username").next().toString());
            user.setName(row.getValues("Name").next().toString());
            list.add(user);
        }
    } catch (XMPPException e) {
        SLog.e(tag, Log.getStackTraceString(e));
    }
    return list;
}
 
開發者ID:jiangzehui,項目名稱:xmpp,代碼行數:33,代碼來源:XmppTool.java


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