本文整理汇总了Java中org.jivesoftware.smack.packet.XMPPError.getCode方法的典型用法代码示例。如果您正苦于以下问题:Java XMPPError.getCode方法的具体用法?Java XMPPError.getCode怎么用?Java XMPPError.getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.packet.XMPPError
的用法示例。
在下文中一共展示了XMPPError.getCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleXMPPException
import org.jivesoftware.smack.packet.XMPPError; //导入方法依赖的package包/类
private void handleXMPPException(XMPPException e) {
XMPPError error = e.getXMPPError();
if (error != null) {
int code = error.getCode();
if (code == 403) {
setStatus(Status.refused);
return;
}
else if (code == 400) {
setStatus(Status.error);
setError(Error.not_acceptable);
}
else {
setStatus(FileTransfer.Status.error);
}
}
setException(e);
}
示例2: handleXMPPException
import org.jivesoftware.smack.packet.XMPPError; //导入方法依赖的package包/类
private void handleXMPPException(XMPPException e) {
XMPPError error = e.getXMPPError();
if (error != null) {
int code = error.getCode();
if (code == 403) {
setStatus(Status.refused);
return;
} else if (code == 400) {
setStatus(Status.error);
setError(Error.not_acceptable);
} else {
setStatus(FileTransfer.Status.error);
}
}
setException(e);
}
示例3: setRoom
import org.jivesoftware.smack.packet.XMPPError; //导入方法依赖的package包/类
public void setRoom(Room r) {
JabberRoom newRoom = null;
try {
if (r instanceof JabberRoom) {
newRoom = (JabberRoom) r;
}
else {
newRoom = roomMgr.getRoomByName(this, r.getName());
}
if (!newRoom.equals(getRoom())) {
final String failedToJoinMessage = newRoom.canJoin(me);
if (failedToJoinMessage != null) {
fireStatus(Resources.getString("Chat.failed_to_join", newRoom.getName(), failedToJoinMessage)); //$NON-NLS-1$
return;
}
leaveCurrentRoom();
currentChat = newRoom.join(this, (JabberPlayer) getUserInfo());
if (newRoom.isOwnedByMe()) {
currentChat.addParticipantStatusListener(userListener);
}
fireStatus(Resources.getString("Chat.joined_room", newRoom.getName())); //$NON-NLS-1$
if (!newRoom.isOwnedByMe() && ! isDefaultRoom(newRoom)) {
new SynchAction(newRoom.getOwningPlayer(), this).actionPerformed(null);
GameModule.getGameModule().warn(Resources.getString("Chat.synchronize_complete")); //$NON-NLS-1$
}
else {
SynchAction.clearSynchRoom();
}
currentChat.addUserStatusListener(kickListener);
monitor.sendRoomChanged();
monitor.sendStatus(me, newRoom);
}
}
// FIXME: review error message
catch (XMPPException e) {
reportXMPPException(e);
String mess = null;
if (e.getXMPPError() != null) {
final XMPPError error = e.getXMPPError();
if (error.getCode() == 407) {
mess = Resources.getString("Chat.not_a_member"); //$NON-NLS-1$
}
else {
mess = e.getXMPPError().getMessage();
if (mess == null) {
mess = e.getXMPPError().getCondition();
}
}
}
else {
mess = e.getMessage();
}
fireStatus(Resources.getString("Chat.failed_to_join", newRoom.getName(), mess)); //$NON-NLS-1$
}
}
示例4: login
import org.jivesoftware.smack.packet.XMPPError; //导入方法依赖的package包/类
private Integer login() {
String username = loginConfig.getUsername();
String password = loginConfig.getPassword();
try {
XMPPConnection connection = XmppConnectionManager.getInstance()
.getConnection();
connection.connect();
connection.login(username, password); // ��¼
// OfflineMsgManager.getInstance(activitySupport).dealOfflineMsg(connection);//����������Ϣ
/**
* ֪ͨ�������û���ǰ��״̬: available--����; unavailable--����
* ��������http://blog.csdn.net/majian_1987/article/details/9930637
*/
connection.sendPacket(new Presence(Presence.Type.available));
if (loginConfig.isNovisible()) {// �����¼
Presence presence = new Presence(Presence.Type.unavailable);
Collection<RosterEntry> rosters = connection.getRoster()
.getEntries();
for (RosterEntry rosterEntry : rosters) {
presence.setTo(rosterEntry.getUser());
connection.sendPacket(presence);
}
}
loginConfig.setUsername(username);
if (loginConfig.isRemember()) {// ��������
loginConfig.setPassword(password);
} else {
loginConfig.setPassword("");
}
loginConfig.setOnline(true);
return Constant.LOGIN_SECCESS;
} catch (Exception xee) {
if (xee instanceof XMPPException) {
XMPPException xe = (XMPPException) xee;
final XMPPError error = xe.getXMPPError();
int errorCode = 0;
if (error != null) {
errorCode = error.getCode();
}
if (errorCode == 401) {
return Constant.LOGIN_ERROR_ACCOUNT_PASS;
}else if (errorCode == 403) {
return Constant.LOGIN_ERROR_ACCOUNT_PASS;
} else {
return Constant.SERVER_UNAVAILABLE;
}
} else {
return Constant.LOGIN_ERROR;
}
}
}