public boolean send(XmppMsg message,String to){
  if (to == null) {
    Log.i("Sending message \"" + message.toShortString() + "\"");
  }
 else {
    Log.i("Sending message \"" + message.toShortString() + "\" to "+ to);
  }
  Message msg;
  MultiUserChat muc=null;
  if (to == null) {
    msg=new Message();
  }
 else {
    msg=new Message(to);
    muc=mXmppMuc.getRoomViaRoomName(to);
  }
  msg.setFrom(mConnection.getUser());
  msg.setBody(mSettings.formatResponses ? message.generateFmtTxt() : message.generateTxt());
  try {
    XHTMLManager.addBody(msg,message.generateXHTMLText());
  }
 catch (  Exception e) {
    Log.d("XHTMLManager error. Ex:" + e.getMessage());
  }
  msg.setType(muc == null ? Message.Type.chat : Message.Type.groupchat);
  if (isConnected()) {
    if (muc == null && to == null) {
      return XmppMultipleRecipientManager.send(mConnection,msg);
    }
 else     if (muc == null) {
      try {
        mConnection.sendStanza(msg);
      }
 catch (      SmackException.NotConnectedException e) {
        Log.e("Send message error. Ex:" + e.getMessage());
        return false;
      }
    }
 else {
      try {
        muc.sendMessage(msg);
      }
 catch (      Exception e) {
        Log.e("Send message MUC error. Ex:" + e.getMessage());
        return false;
      }
    }
    return true;
  }
 else {
    boolean result=mClientOfflineMessages.addOfflineMessage(msg);
    Log.d("Adding message: \"" + message.toShortString() + "\" to offline queue, because we are not connected. Status="+ statusString());
    return result;
  }
}

public boolean send ( XmppMsg message , String to ) { if ( to == null ) { Log . i ( "Sending message \"" + message . toShortString ( ) + "\"" ) ; } else { Log . i ( "Sending message \"" + message . toShortString ( ) + "\" to " + to ) ; } Message msg ; MultiUserChat muc = null ; if ( to == null ) { msg = new Message ( ) ; } else { msg = new Message ( to ) ; muc = mXmppMuc . getRoomViaRoomName ( to ) ; } msg . setFrom ( mConnection . getUser ( ) ) ; msg . setBody ( mSettings . formatResponses ? message . generateFmtTxt ( ) : message . generateTxt ( ) ) ; try { XHTMLManager . addBody ( msg , message . generateXHTMLText ( ) ) ; } catch ( Exception e ) { Log . d ( "XHTMLManager error. Ex:" + e . getMessage ( ) ) ; } msg . setType ( muc == null ? Message . Type . chat : Message . Type . groupchat ) ; if ( isConnected ( ) ) { if ( muc == null && to == null ) { return XmppMultipleRecipientManager . send ( mConnection , msg ) ; } else if ( muc == null ) { try { mConnection . sendStanza ( msg ) ; } catch ( SmackException . NotConnectedException e ) { Log . e ( "Send message error. Ex:" + e . getMessage ( ) ) ; return false ; } } else { try { muc . sendMessage ( msg ) ; } catch ( Exception e ) { Log . e ( "Send message MUC error. Ex:" + e . getMessage ( ) ) ; return false ; } } return true ; } else { boolean result = mClientOfflineMessages . addOfflineMessage ( msg ) ; Log . d ( "Adding message: \"" + message . toShortString ( ) + "\" to offline queue, because we are not connected. Status=" + statusString ( ) ) ; return result ; } }
sends a xmpp message , but only if we are connected this method is thread safe .
