Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
sanbsw #1
Member since Nov 2014 · 4 posts
Group memberships: Members
Show profile · Link to this post
Subject: Sample for message receipt/ack
Hi,

I need a solution to verify if a message that has been sent to another client has been received. It would be nice to see if the message has been successfully dispatched to the server and then delivered to the recipient.

I tried different approaches without success.

1) I tried SendAndAck() but the Callback is never getting called.

  1.     Private Sub cmdSend_Click(sender As Object, e As System.EventArgs) Handles cmdSend.Click
  2.       Dim msg = New Client.Message() With { _
  3.               .Type = MessageType.chat, _
  4.               .[To] = _jid, _
  5.               .Body = rtfSend.Text, _
  6.               .Id = Guid.NewGuid().ToString() _
  7.               }
  8.  
  9.       _xmppClient.SendAndAck(msg, AddressOf SendAndAckCallback)
  10.    End Sub
  11.  
  12.    Private Sub SendAndAckCallback(sender As Matrix.Xml.XmppXElement, e As Matrix.Xmpp.StreamManagement.Ack.AckEventArgs)
  13.        'this is never getting called.
  14.    End Sub

2) I tried to add a Request to the message but I didn't get any response back in the OnMessage event.

  1.     Private Sub cmdSend_Click(sender As Object, e As System.EventArgs) Handles cmdSend.Click
  2.       Dim msg = New Client.Message() With { _
  3.               .Type = MessageType.chat, _
  4.               .[To] = _jid, _
  5.               .Body = rtfSend.Text, _
  6.               .Id = Guid.NewGuid().ToString() _
  7.               }
  8.  
  9.       msg.Add(New Receipts.Request())
  10.  
  11.       _xmppClient.Send(msg)
  12.    End Sub
  13.  
  14.    Private Sub OnMessage(sender As Object, e As MessageEventArgs)
  15.       'no receipt notification arrives here
  16.    End Sub

I am using Openfire v.3.9.3

Thank you!

- Christoph
This post was edited on 2014-11-13, 11:19 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
the "SendAndAck" feature is based on XEP-0198: Stream Management.
I don't think that XEP-0198 is supported yet by the Openfire server.

Quote by sanbsw:
I need a solution to verify if a message that has been sent to another client has been received. It would be nice to see if the message has been successfully dispatched to the server and then delivered to the recipient.

What you describe here sounds to me like you need End-to-End delivery receipts. Those are defined in XEP-0184: Message Delivery Receipts

XEP-0184 is implemented in the MatriX Message class.

Before you send a message add this line of code. It also adds a message id automatically when none is set.

  1. msg.RequestReceipt()

when you receive one check if a receipt is requested:

  1. If msg.ReceiptRequested then
  2.    Dim rcpMsg As new Client.Message(msg.From)
  3.    rcpMsg.DeliveryReceipt(msg.Id)
  4.    xmppClient.Send(rcpMsg)
  5. End If

The sender then can check for incoming message receipts with the following code:

  1. If Not IsNothing(msg.Received) then
  2.    Dim isReceived As String = msg.Received.Id
  3.    '// more code goes here
  4. End If

you could of course write a nice wrapper around this with the latest TAP pattern.
This post was edited on 2014-11-13, 11:52 by Alex.
Avatar
sanbsw #3
Member since Nov 2014 · 4 posts
Group memberships: Members
Show profile · Link to this post
Thank you. Works great!
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: