Beispiel #1
0
  /** �ر����� */
  public void closeConnection() {
    if (connection != null) {
      // �Ƴ��B�ӱO
      // connection.removeConnectionListener(connectionListener);
      if (connection.isConnected()) connection.disconnect();

      connection = null;
    }
    Log.i("XmppConnection", "�P�]�B��");
  }
Beispiel #2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * com.bearmaster.talk.services.impl.ChatService#login(java.lang.String,
  * java.lang.String)
  */
 @Override
 public void login(String username, String password) throws TalkException {
   if (connection != null) {
     try {
       if (!connection.isConnected()) {
         LOGGER.debug("Connecting...");
         connection.connect();
       }
       LOGGER.debug("Attemtping login...");
       connection.login(username, password);
       LOGGER.debug("Login completed.");
       Presence presence = new Presence(Presence.Type.available);
       presence.setMode(Presence.Mode.available);
       connection.sendStanza(presence);
       LOGGER.debug("Presence set to available");
     } catch (SmackException | IOException | XMPPException e) {
       throw new TalkException("Error during login", e);
     }
   } else {
     throw new IllegalStateException(ERROR_CONNECTION_IS_NOT_INITIALISED);
   }
 }