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


Java XMPPException.getXMPPError方法代碼示例

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


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

示例1: formatXMPPError

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
private static String formatXMPPError(XMPPException e) {
  final XMPPError error = e.getXMPPError();
  if (error == null) {
    return Resources.getString("Server.server_error", e.getMessage(), "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
  }
  else {
    return Resources.getString("Server.server_error", e //$NON-NLS-1$
        .getXMPPError().getMessage(), e.getXMPPError().getCondition(), e
        .getXMPPError().getCode());
  }
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:12,代碼來源:JabberClient.java

示例2: join

import org.jivesoftware.smack.XMPPException; //導入方法依賴的package包/類
public MultiUserChat join(JabberClient client, JabberPlayer me) throws XMPPException {
  MultiUserChat chat = new MultiUserChat(client.getConnection(), getJID());
  chat.join(StringUtils.parseName(me.getJid()));

  if (!chat.isJoined()) {
    return null;
  }

  try {
    // This is necessary to create the room if it doesn't already exist
    // Configure the options we needs explicitly, don't depend on the server supplied defaults
    final Form configForm = chat.getConfigurationForm().createAnswerForm();
    configForm.setAnswer(JABBER_MEMBERSONLY, isStartLocked());
    configForm.setAnswer(JABBER_ALLOW_INVITES, false);
    configForm.setAnswer(JABBER_CHANGE_SUBJECT, false);
    configForm.setAnswer(JABBER_MODERATED, false);
    configForm.setAnswer(JABBER_PASSWORD_PROTECTED, false);
    configForm.setAnswer(JABBER_PERSISTENT, false);
    configForm.setAnswer(JABBER_PUBLIC_ROOM, true);

    chat.sendConfigurationForm(configForm);
    ownedByMe = true;
    owners.clear();
    addOwner(jid);
  }
  catch (XMPPException e) {
    // 403 code means the room already exists and user is not an owner
    if (e.getXMPPError() != null && e.getXMPPError().getCode() != 403) {
      throw e;
    }
  }

  chat.addMessageListener(client);
  return chat;
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:36,代碼來源:JabberRoom.java

示例3: setRoom

import org.jivesoftware.smack.XMPPException; //導入方法依賴的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$
  }
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:56,代碼來源:JabberClient.java


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