How to get Openfire chat history on Android device

2019-01-25 09:35发布

问题:

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.

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.

回答1:

You can get groupchat history by using following code:

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


multiUserChat.join("username", "password", history, SmackConfiguration.getPacketReplyTimeout());


回答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.



回答3:

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.