当前位置: 首页>>代码示例>>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;未经允许,请勿转载。