Not logged in. · Lost password · Register
Forum: MatriX RSS
sambataro #1
User title: Developer
Member since May 2014 · 7 posts · Location: London
Group memberships: Members
Show profile · Link to this post
Subject: How to get private chat history?
Hello everyone,

I am creating a jabber client for HipChat. When I join a groupchat, the server usually sends me the last 40-50 messages sent to the room (which is fine).

However, I have no idea how to get the chat history for private 1-1 conversations. Is there a way using MatriX to achieve this?

Thanks a lot for the support

Nicholas
Avatar
Alex #2
Member since Feb 2003 · 4295 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
private chat is different. For group chats you get the history so that you can know what was going on the room before you joined. In private and 1:1 chat you got every single message before, and there is none you missed.
For private chat the most chat clients use a local database for archiving the messages. From tis database you can lookup the messages at any time later when you need to,

There are also server side extensions for 1:1 chat message archiving.
XEP-0136: Message Archiving
But you can use this only when the extension is running on the HipChat server.
Avatar
longvk #3
Member since Jul 2016 · 7 posts
Group memberships: Members
Show profile · Link to this post
Hi Alex, I currently use Monitor plugin on my chat server and now it can store private chat history but how can i get it on client side, there is no API in matrix document tell about this prob
Avatar
Alex #4
Member since Feb 2003 · 4295 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Can you please point us to the documentation of the Monitor plugin for your server? I am not familiar with it.

Alex
Avatar
longvk #5
Member since Jul 2016 · 7 posts
Group memberships: Members
Show profile · Link to this post
https://www.igniterealtime.org/projects/openfire/plugins.jsp

Monitoring Service
Monitors conversations and statistics of the server.

version: 1.5.4    minOpenFireVersion: 4.0.0    Date: Apr 27, 2016
Avatar
longvk #6
Member since Jul 2016 · 7 posts
Group memberships: Members
Show profile · Link to this post
Readme: https://www.igniterealtime.org/projects/openfire/plugins/m…
Avatar
Alex #7
Member since Feb 2003 · 4295 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
this extension is based on XEP-0136: Message Archiving which is implemented in MatriX in the Matrix.Xmpp.MessageArchiving namespace.

There are already some threads about this in the forum, eg. here:
http://forum.ag-software.net/thread/1757-How-to-retrieve-c…

Alex
Avatar
longvk #8
Member since Jul 2016 · 7 posts
Group memberships: Members
Show profile · Link to this post
Thank you for your help. I downloaded new matrix dll which have API Matrix.Xmpp.MessageArchiving. I used the following code to get private message :

  1. public void GetPrivateChat(long userId)
  2. {
  3.     var jid = GetJId(userId);
  4.     var list = new Matrix.Xmpp.MessageArchiving.Retrieve
  5.     {
  6.         With = GetJId(userId)
  7.     };
  8.  
  9.     var iq = new Matrix.Xmpp.Client.Iq
  10.     {
  11.         Type = Matrix.Xmpp.IqType.Get,
  12.         Query = list
  13.     };
  14.     iq.GenerateId();
  15.     client.IqFilter.SendIq(iq, GetPrivateChatCallback);
  16. }

I can now get the history chat but only those message after a time, newest message don't appear. Only after a time when conversation is not in active conversation, then i can get them. How can i get newest message?

edit: Only the first conversation return, the rest is missing. Can you help me?
This post was edited 5 times, last on 2016-08-08, 11:07 by Alex.
Avatar
Alex #9
Member since Feb 2003 · 4295 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by longvk:
I can now get the history chat but only those message after a time, newest message don't appear. Only after a time when conversation is not in active conversation, then i can get them. How can i get newest message?

edit: Only the first conversation return, the rest is missing. Can you help me?

are you archiving the message manual, or are they archived automatically on the server?
See also:
www.xmpp.org/extensions/xep-0136.html#manual

If the server archives them automatically then you have to look at the server settings, or the server archives them with some delay always in chunks.. You have to consult your server vendor then.

Alex
Avatar
longvk #10
Member since Jul 2016 · 7 posts
Group memberships: Members
Show profile · Link to this post
currently i think it is automatically! but still not get your point, this is screenshot of archiving setting [Image: http://i.imgur.com/Z70OIXt.png]
This post was edited on 2016-08-08, 11:31 by longvk.
Avatar
Alex #11
Member since Feb 2003 · 4295 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
I am not familiar with the archiving plugin of your server, please consult the server vendor about this.

On Your screenshot there is Max-time and Idle-time. It looks to me like your server is using this setting to find chat messages which belong to a conversation and archive them together, which explains a delay.

Alex
Avatar
longvk #12
Member since Jul 2016 · 7 posts
Group memberships: Members
Show profile · Link to this post
I am using unity as client. So that i must use mono 3.5 matrix.dll which doesn't has MessageArchiving. Can you provide me the code that i can query all the chat of 1 user to another (include all message in all conversation) ?
This post was edited on 2016-08-10, 05:54 by longvk.
Avatar
Alex #13
Member since Feb 2003 · 4295 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Also the Mono builds include message archiving. Please look at the Matrix.Xmpp.MessageArchiving namespace
Avatar
longvk #14
Member since Jul 2016 · 7 posts
Group memberships: Members
Show profile · Link to this post
I try to use that namespace but not found! may be it's in mono 4.5 matrix.dll. One question 4.5 is .net 4.5 right? If so i can not use it because unity only support .net 3.5
Avatar
Alex #15
Member since Feb 2003 · 4295 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
are you using the latest NuGet from here?
https://www.nuget.org/packages/MatriX.Mono/

yes, 3.5 and 4.5 stands for the .NET version. But its definitely included in both builds, if you don't see it you must use old builds.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: MatriX RSS