robbiehanson / XMPPFramework

An XMPP Framework in Objective-C for Mac and iOS
Other
5.91k stars 2.09k forks source link

MUC room message history not getting fully #1166

Open NagarajuMetavoxx opened 4 years ago

NagarajuMetavoxx commented 4 years ago

Hi, I'm signing into the app and created the MUC room and joining the room. I'm only getting 20 messages, but in my MUC room have more than 20. What I'm doing wrong, can any one suggest me.

Here is my MUC configuration : -

-(void)JoinMucRoom { NSString subscriberName=@"nagaraj"; //NSLog(@"Room Name ----->%@",[def objectForKey:@"room_name"]); XMPPRoomMemoryStorage _roomMemory = [[XMPPRoomMemoryStorage alloc]init]; NSString roomname = self.groupName; NSString roomExtenction = @"@conference.xxxxxxxxx.com"; NSString roomID = [NSString stringWithFormat:@"%@%@",roomname,roomExtenction]; XMPPJID roomJID = [XMPPJID jidWithString:roomID]; room = [[XMPPRoom alloc] initWithRoomStorage:_roomMemory jid:roomJID dispatchQueue:dispatch_get_main_queue()]; [room activate:self.xmppStream]; [room addDelegate:self delegateQueue:dispatch_get_main_queue()]; [room joinRoomUsingNickname:subscriberName history:nil]; }

alinradut commented 4 years ago

The default room history is not to be relied upon, as most servers lose the messages when they are restarted.

You'll probably want to enable MAM for the rooms to make sure all messages are permanent. You can fetch the room MAM archive by calling

    let mam = XMPPMessageArchiveManagement()
    mam.activate(xmppStream)
    mam.addDelegate( ... )

    let formatter = DateFormatter()
    formatter.locale = Locale(identifier: "en_US_POSIX")
    formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"

    var fields = [DDXMLElement]()
    fields.append(XMPPMessageArchiveManagement.field(withVar: "start", type: "text-single", andValue: formatter.string(from: startDate)))

    mam.resultAutomaticPagingPageSize = 150
    mam.retrieveMessageArchive(at: room.roomJID, withFields: fields, with: nil)
NagarajuMetavoxx commented 4 years ago

I've fetched the room MAM and I'm getting the xmpp message from the mam delegate method. Now how I can get the body of the message from the below.

`

Hail to thee

`

devarshisolvative commented 3 years ago

I have able to fetch the rooms, and able to join the rooms. But, getting only 20 messages. I have also applied the history element.What I'm doing wrong.Can any one help me.

let xmppRoom = XMPPRoom(roomStorage: XMPPRoomHybridStorage.sharedInstance(), jid: XMPPJID(string: roomId!)!) xmppRoom.activate(xmppStream) xmppRoom.addDelegate(self, delegateQueue: DispatchQueue.main) let historyElement = DDXMLElement(name: "history") historyElement.addAttribute(withName: "maxstanzas", stringValue: "1000") xmppRoom.join(usingNickname: userJabberId, history: historyElement)

arunpandiyanp commented 2 years ago

@devarshi089 found any solution?

vitalyster commented 2 years ago

@arunpandiyanp 20 messages is a common default of the MUC component on various XMPP servers. You should explicitly configure your XMPP server limits to allow to send more messages

arunpandiyanp commented 2 years ago

Hi @vitalyster thank you for your reply , this code is working me to fetch all the history chat

       let mam = XMPPMessageArchiveManagement()
        mam.activate(xmppController.xmppStream)
        xmppMAM?.addDelegate(self, delegateQueue: .global(qos: .background))

            mam.resultAutomaticPagingPageSize = 150
        let roomJID = XMPPJID(string: joinOrCreateRoomString)

            mam.retrieveMessageArchive(at: roomJID, withFields: nil, with: nil)
vitalyster commented 2 years ago

@arunpandiyanp this is a different history storage protocol and it may work and may not work depending on server configuration too