Message id issue connecting chat between iOS and Android in Quickblox - android

I'm having an issue connecting an iOS and Android device with their corresponding QBChat libraries, with the message ID's.
Message objects in Quickblox's iOS library are defined as QBChatMessage objects, that doesn't exist in Quickblox's Android library (which delegates them to a Message class in SMACK library).
The problem is that QBChatMessage class manages message id's as integers, while Message class manages them as Strings. Every message sent from my Android device has a 7-character unique string + a number with the message's position in SMACK chat. When my iPhone receives the message, its ID is a number with the ID from SMACK parsed as much as it could, as in this communication sample (taken from the Android device):
SENT <message id="D64u5-4" to="102521-1799#chat.quickblox.com" from="132505-1799#chat.quickblox.com/Smack" type="chat"><body>{"content":{"text":"hello"},"type":1}</body><thread>7J9230</thread></message>
SENT <message id="D64u5-5" to="102521-1799#chat.quickblox.com" from="132505-1799#chat.quickblox.com/Smack" type="chat"><body>{"content":{"text":"yeah"},"type":1}</body><thread>7J9230</thread></message>
SENT <message id="D64u5-6" to="102521-1799#chat.quickblox.com" from="132505-1799#chat.quickblox.com/Smack" type="chat"><body>{"content":{"text":"test"},"type":1}</body><thread>7J9230</thread></message>
RCV <message id="0" from="102521-1799#chat.quickblox.com" type="chat" xmlns="jabber:client" to="132505-1799#chat.quickblox.com"><body>{"content":{"text":"hello"},"type":1}</body></message>
RCV <message id="1" from="102521-1799#chat.quickblox.com" type="chat" xmlns="jabber:client" to="132505-1799#chat.quickblox.com"><body>{"content":{"text":"yeah?"},"type":1}</body></message>
RCV <message id="2" from="102521-1799#chat.quickblox.com" type="chat" xmlns="jabber:client" to="132505-1799#chat.quickblox.com"><body>{"content":{"text":"yeah!"},"type":1}</body></message>
Message's ID is important for me, in order of database storage. How is this possible? What should I do to solve this issue?
Thanks, kind regards! :)

Daniel, sounds good.
Is changing type of QBChatMessages.ID to NSString will solve your issue?
Will do that in next release. If you haven't time to wait - just write with your request to assist#quickblox.com, will make special build of SDK for you

Below is my Android code for group chat:
/* Sends messages */
public void sendChatMessage(String text)
{
Message message = muc.createMessage();
message.setBody(text);
message.setPacketID("ABC_1");
muc.sendMessage(message);
}
/* Listens for messages */
public void receiveMessage()
{
muc.addMessageListener(new PacketListener() {
public void processPacket(Packet packet)
{
final Message message = (Message) packet;
log.i("packed id: ", packet.getPacketID());
log.i("message id: ", message.getPacketID());
}
});
}
The output I see in logcat is
packet id: null
message id: null
Could you please tell me why the IDs are null? Am I missing something here?

Related

Smack Push Notification not working

I am using Smack library to get XMPP pubsub requests in my Android App.
I want to send alert from 1 phone which is received on another phone as push notification popup.
On debugging, control returns null due to this code in Smack 4.2.0 library's ChatManager.java class.
EntityJid userJID = from.asEntityJidIfPossible();
if (userJID == null) {
LOGGER.warning("Message from JID without localpart: '" + message.toXML() + "'");
return null;
}
My from isnt null,ofc... but, my asEntityjidIfPossibe is null.
My Iq is as follows:
<iq
to="pubsub.foo"
from="notifier#foo"
type="set"
id="1523272621323">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<publish xmlns="http://jabber.org/protocol/pubsub"
node="/home/foo/notifier/c7215880-a36e-4cb9-bdd3-441cf9c29c31/pqr">
<item id="item11523272621323">
<json xmlns="urn:xmpp:json:0">
{"id":"b7da305d-77c2-422a-9c95-7ec8a347192e",
"orgId":"c7215880-a36e-4cb9-bdd3-441cf9c29c31",
"user_id":"f0622ed6-860f-4f4e-9b11-c4ab6cb8cd66",
"username":"xyz",
"subject":"Message",
"body":"hello all",
"priority":"NORMAL",
"ack_required":false,
"users":["pqr"],
"replyTo":["/home/foo/notifier/c7215880-a36e-4cb9-bdd3-441cf9c29c31/xyz",
"/home/foo/notifier"]}
</json>
</item>
</publish>
</pubsub>
</iq>
All I want is to see if message sent is recieved or not? And how to get data to process it...Data is sent perfectly on the server from the sending phone.
On recieving device,
I get this message TWICE,
Message from JID without localpart: '<message to='xyz#foo/5301412210663914056363834' from='pubsub.foo'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='/home/foo/notifier/c7215880-a36e-4cb9-bdd3-441cf9c29c31/xyz'><retract id='item11523351450156'/></items></event></message>'

Unable to get Joined Chat Rooms using asmack

My problem is i am not been able to receive joined chat rooms. I am using the openfire server 3.8.2 and asmack library asmack-android-16.jar. I receive item-not-found error when i call getJoinedRooms function. though i can see the user is joined in the room from the admin console. Is it the server problem or the client problem or some issue with asmack? Please tell me if someone is able to get joined chat rooms using openfire and asmack for android.
here is how i am call the function:
Iterator RoomsIterator=MultiUserChat.getJoinedRooms(MyService.getConnection(),"user#192.168.1.3");
i also tried this but it gives no response form server:
Iterator RoomsIterator=MultiUserChat.getJoinedRooms(MyService.getConnection(),"user#192.168.1.3/Smack");
Please help me with my problem
Thanks in advance.
I solved my problem by adding a packet listener after call get joined rooms function.. as i was getting an empty list but when i debug i check that the rooms was getting returned in the resultant xml stanze that was sent by the server therefore i run the getjoinedroom function of asmack and then i manually add ha packet listener like this:
public void AddPacketListener(){
PacketFilter filter = new IQTypeFilter(IQ.Type.RESULT);
MyService.getConnection().addPacketListener(new PacketListener()
{
public void processPacket(Packet paramPacket) {
if(paramPacket.getFrom().equals(MyService.getConnection().getUser())){
String xml=paramPacket.toXML();
String from[];
System.out.println(xml);
from=paramPacket.getFrom().split("/");
Pattern pattern = Pattern.compile("<item jid=\"(.*?)/>");
Matcher matcher = pattern.matcher(xml);
String parts[];
Roomlist.clear();
while (matcher.find()) {
parts=matcher.group(1).split("#");
Roomlist.add(parts[0]);
}
return;
}
}
},filter);
}

Asmack android: Create a custom packet and register extension

I am using the library Asmack to use XMPP on an android app, the server sends custom Stanza
<notification xmlns="jabber:client" from="admin#api.pp.gs" to="1eef368606cb459b847809a0430bfa1f#api.pp.gs/iMac-de-Thomas" id="1457247499">
<body>lol</body>
</notification>
I would like to be able to listen these packets, I try to use PacketExtensionProvider but without success. Here my code to listen the packet:
xmppConnection.addPacketListener(new PacketListener()
{
#Override
public void processPacket(Packet packet)
{
Log.i("K:", "cool " + packet.getClass().toString());
}
}, new MyPaquetFilter());
Where MyPaquetFilter return always true for test purpose.
How should I use the PacketManager, PacketExtension stuff in order to get my custom paquet here?
In order to be able to receive a custom packet you need to first create a Provider, either an IQProvider or an PacketExtensionProvider, and register that Provider with ProviderManager, so that's considered for parsing when receiving a packet.
You didn't showed us your custom PacketExtensionProvider nor how you are registering it with the ProviderManager. And just to absolute precise, you need to wrap your custom extension notification within the message element if you use PacketExtensionProvider.

asmack pubsub getItems error

I'm trying to publish some information to server using the Pubsub nodes.unfortunately,I failed to retrieve the node that published before.Just very similar as the problem in the following link:
http://community.igniterealtime.org/message/199690#199690
to be specific, the code snippets like following :
try {
LeafNode node = mPubsub.getPEPNode(USEINFONODE,mFrom);
if(null != node){
List<Item> items = node.getItems();
Log.i("items",items.toString());
}
} catch (XMPPException e) {
Log.e("userInfoExtension","error : and the error is " + e.toString());
}
and the output error is no resposne from server.
the output of the debug is just like this:
<iq id="B9tI0-4" to="pubsub.mymachine" type="get"><query xmlns="http://jabber.org/protocol/disco#info" node="theNode"></query></iq>
<iq id="B9tI0-5" to="pubsub.mymachine" type="get"><pubsub xmlns="http://jabber.org/protocol/pubsub"><items node='theNode'/></pubsub></iq>
However according to the link mentioned above, the expected iq stanza shall be like this:
<iq type='get'
from='notifyserver#mymachine'
to='pubsub.mymachine'
id='items1'>
<query xmlns='http://jabber.org/protocol/disco#items'
node='theNode'/>
</iq>
so It shows that I miss the from field in the iq stanza,I'm wondering how can I put the from ='client#server' into the iq stanza. I have tried asmack libraries including :
asmack-android-7.jar , asmack-android-7-beem.jar asmack-android-16-beem.jar,all failed.
Can anyone help with this? Thanks very much.
I have found that it has something to do with receiving the packet. actually I have received the packet that I needed, the trouble is that the packet may can not be processed by smack in somewhere, and it will throw no response from sever exception.
so I think the problem is actually not receiving incoming packet correctly .
so does in my other question:
http://stackoverflow.com/questions/14357707/how-to-send-and-listen-to-custom-xmpp-presence-packet-with-asmack-the-library
I'm sorry to mislead you ! the error is caused by my extension provider which lead the parsing
packet into an endless loop, thus ,caused the no response from server exception.

Sending and Receiving IQ Packets ASMACK/SMACK Android XMPP

I would highly appreciate if someone can help me how to recieve iq packets with ASMACK, i am sending raw iq packets but not able to receive it,
I have registered the iq packets programatically before making a connection but still not getting reponse,
pm.addIQProvider("vCard", "vcard-temp", new VCardProvider());
final IQ iq = new IQ() {
public String getChildElementXML() {
return "<iq from='test#XX.XX.XX.XX' id='v1' to='test#XX.XX.XX.XX' type='get'><vCard xmlns='vcard-temp'/></iq>";
}
};
iq.setType(IQ.Type.GET);
connection.sendPacket(iq);
connection.addPacketListener(new MyPacketListener(),new PacketTypeFilter(IQ.class));
First of all, try setting your packet listener before you send the packet. It is an asynchronous protocol and it is possible that the response is being returned before your listener is setup to receive it.
Then try setting -DsmackDebugEnabled=true to check that there is an actual response to your send.
You can implement a Packet Listner method, the processPacket(Packet packet) method will give you the incoming packets.
Here is a stack thread which explains the same issue aSmack - Packet to XML using Packet Listener outputs nullable elements

Categories

Resources