I want to send
<message id="qm5Dx-8"
to="abc"
type="chat"
from="abc"
msgType="2"
msgTimeStamp="1413971599039"
fileSize="18 MB"
fileHeight="300"
fileWidth="300"
thumbnail="abc"
mediaURL=""
serverMediaURL="xyz"
isFromMe="1"
status="1"><body>Image</body><request xmlns='urn:xmpp:receipts'/></message>
The way i am constructing the custom message is :
public class MyCustomMessage extends Message{
public MyCustomMessage(){
super();
}
public MyCustomMessage(String to, Type type){
super(to, type);
}
private String msgType ;
private String msgTimeStamp ;
private String isFromMe ;
private String status ;
private String mediaURL ;
private String serverMediaURL ;
private String fileSize ;
private String fileHeight ;
private String fileWidth ;
private String thumbnail ;
@Override
public String toXML() {
String XMLMessage = super.toXML();
String XMLMessage1 = XMLMessage.substring(0, XMLMessage.indexOf(">"));
String XMLMessage2 = XMLMessage.substring(XMLMessage.indexOf(">"));
if (this.msgType != null) {
XMLMessage1 += " msgType="" + this.msgType + """;
}
if (this.msgTimeStamp != null) {
XMLMessage1 += " msgTimeStamp="" + this.msgTimeStamp + """;
}
if (this.fileSize != null) {
XMLMessage1 += " fileSize="" + this.fileSize + """;
}
if (this.fileHeight != null) {
XMLMessage1 += " fileHeight="" + this.fileHeight + """;
}
if (this.fileWidth != null) {
XMLMessage1 += " fileWidth="" + this.fileWidth + """;
}
if (this.thumbnail != null) {
XMLMessage1 += " thumbnail="" + this.thumbnail + """;
}
if (this.mediaURL != null) {
XMLMessage1 += " mediaURL="" + this.mediaURL + """;
}
if (this.serverMediaURL != null) {
XMLMessage1 += " serverMediaURL="" + this.serverMediaURL + """;
}
if (this.isFromMe != null) {
XMLMessage1 += " isFromMe="" + this.isFromMe + """;
}
if (this.status != null) {
XMLMessage1 += " status="" + this.status + """;
}
return XMLMessage1 + XMLMessage2;
}
// Setters Getters of all these fields..
}
Then after adding required fields in SmackableImplement class, i m calling mXMPPConnection.sendPacket(customMessage);
but m not receiving any packet. my connections is being closed everytime after calling this method. I have gone through many tutorials but couldnt find any solution...tell me where m mistaken.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…