本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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");
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}