10

I am developing a chatting application, where user will chats with one of the domain expert's group member. user uses my android app and domain expert uses spark web for chatting. I made Openfire setup and Spark web setup and developed Android chatting app with aSmack library. My app users are able to chat with domain expert. So far it is fine. Now I would like show chat history of user with any or specific expert on Android device. After surfing web, I am able to install Monitoring Service plugin for my open fire server, which is showing chat history of user on Admin side as shown below.enter image description here

Now I would like to show this history in my Android app, How can I achieve this. Any suggestions, most welcome. Am I moving in the right direction? or there any simple ways to do my job? Any info on where this chat history will be stored in Open fire Database, so that I can make SQL queries and get data using webservices is most appreciated.

Flow
  • 22,048
  • 13
  • 91
  • 147
Ganesh K
  • 2,435
  • 6
  • 43
  • 72

3 Answers3

4

You can get groupchat history by using following code:

DiscussionHistory history = new DiscussionHistory();
history.setMaxStanzas(0);


multiUserChat.join("username", "password", history, SmackConfiguration.getPacketReplyTimeout());
Ravindra Kushwaha
  • 6,734
  • 9
  • 42
  • 85
BMM
  • 151
  • 1
  • 1
  • 11
  • 1
    I am able to get group chat history using this..but can anyone tell me how to get one to one chat history? – BMM May 12 '15 at 07:07
  • i have used the above code to cod in the group,and now how do i get the chat history in my application. – Priya Sep 07 '16 at 12:36
  • It means we do not get the history from the Xmpp smack.As i notice in IOS , they are easily getting the one to one chatting history. If there any way to get the XMPP chatting history.Please let me know.. Thanks – Ravindra Kushwaha Oct 10 '16 at 12:19
  • @RavindraKushwaha we have maintain a local database for history unlike ios. – BMM Oct 17 '16 at 07:20
  • @Priya when u connect to the group ,automatically messages will be received in the listener. – BMM Oct 17 '16 at 07:21
2

If you are using MUC (XEP-45) then you can request the discussion history when entering a MUC. See XEP-45 7.2.14 Discussion History. When using (a)Smack, this mean that you have to use MultiUserChat.join(String nickname, String password, DiscussionHistory history, long timeout) to get the History.

Flow
  • 22,048
  • 13
  • 91
  • 147
  • 1
    I don't want user to join in any chat rooms to get history. I want history of user when he is offline. I want chat history of user with another user not with group. – Ganesh K Jan 27 '13 at 14:36
  • Hi @vrs i was also looking for the same requirement. Are you able to find any code snippet or a sample ?? – KK_07k11A0585 Aug 23 '13 at 14:38
  • No simple way found. As mentioned only from data base I am able to get that info. – Ganesh K Sep 18 '14 at 09:27
  • 1
    If i want to retrieve one to one chat history than what i do. I search on internet but i am not getting proper ans – Mahi Nov 25 '14 at 11:32
  • @Flow Please check out my question for retrieving chat history http://stackoverflow.com/questions/27125713/how-to-retrieve-one-to-one-chat-history-from-openfire-using-asmack-android – Mahi Nov 26 '14 at 06:05
2

I added Monitoring service Plugin to openfire, which created some additional tables to store chat conversation details between any 2 accounts. Monitoring service also gives you data base query statics. From admin panel data base statics, I am able to get in which tables, which columns this chat details got stored. Also required queries. using the above info, My back end team has written web services to get required info. This is the way I implemented.

Ganesh K
  • 2,435
  • 6
  • 43
  • 72
  • Can you Please share in which tables the messages were saved – Prakash May 23 '15 at 15:12
  • @vrs , me too facing the same problem,i added the Monitoring plugin,where the additional table will be create .. can you please elaborate your answer. – Priya Sep 07 '16 at 12:33
  • Sorry, I forgot. Don't have that project setup now. – Ganesh K Sep 07 '16 at 12:46
  • It means we do not get the history from the Xmpp smack.As i notice in IOS , they are easily getting the one to one chatting history. If there any way to get the XMPP chatting history.Please let me know.. Thanks – Ravindra Kushwaha Oct 10 '16 at 12:19