Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
zco_dev #1
Member since May 2015 · 3 posts
Group memberships: Members
Show profile · Link to this post
Subject: Message Send Callback
We are sending an xmpp message to server using the below C# code.
                              
//Send Message
  1. var msg = new Matrix.Xmpp.Client.Message
  2. {                
  3.    Body = messageText
  4. };
  5. xmppClient.Send(msg);

Is there a way to invoke a call back, when the message is successfully saved in database. Now we don't have any option to know whether the message is saved or not in the database. and if it is failed we need to send the message again.
This post was edited on 2016-02-17, 14:50 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
There are many different ways to achieve this.
Because you are saying you want to know when the message was saved in the database I think you are looking for a "end to end" solution on this. When the save to database happens on a client.

For "end to end" notifications I would suggest to use XEP-0184 http://www.xmpp.org/extensions/xep-0184.html or something similar.

Alex
Avatar
zco_dev #3
Member since May 2015 · 3 posts
Group memberships: Members
Show profile · Link to this post
Subject: Message Send Callback
We should be fine if we can get a callback from the XMPP server as soon as the message is delivered to XMPP. We cannot depend on XEP-0184: Message Delivery Receipts OR XEP-0198: Stream Management because, as per our understanding both requires the client to acknowledge the message receipt.

 For better understanding, I will describe our workflow in steps. 

1. Admin will send a message to a client.
2. As soon as the message is delivered to XMPP server, we want  the status (Success/ Failed) from XMPP.
3. Due to unforeseen reasons, if the message is not delivered to the XMPP, we want to resend that particular message.
4. We are not expecting a delivery status or read/ unread status from the client as this will not serve our purpose.

I have seen other functions like  "PubSubManager.PublishItem()", "MucManager.RequestRoomConfiguration()" accepting callback functions which provides the "IqType". Is there any similar functionality for "xmppClient.Send()" ?
If it is not there , can you suggest a workaround ?
Can we use the onError() event to track the errors in delivering the message to XMPP? Will this help me to identify the exact message that failed to deliver?
Avatar
Alex #4
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by zco_dev:
For better understanding, I will describe our workflow in steps. 

1. Admin will send a message to a client.
2. As soon as the message is delivered to XMPP server, we want  the status (Success/ Failed) from XMPP.
3. Due to unforeseen reasons, if the message is not delivered to the XMPP, we want to resend that particular message.
4. We are not expecting a delivery status or read/ unread status from the client as this will not serve our purpose.

I have seen other functions like  "PubSubManager.PublishItem()", "MucManager.RequestRoomConfiguration()" accepting callback functions which provides the "IqType". Is there any similar functionality for "xmppClient.Send()" ?
If it is not there , can you suggest a workaround ?
Can we use the onError() event to track the errors in delivering the message to XMPP? Will this help me to identify the exact message that failed to deliver?

The PubSub and Multi User Chat functions you listed above are based on Iq stanzas and not messages. Iqs in XMPP require always a reply back from the recipient (server or client). This is why you can define a callback there. Whenever the reply comes in the callback gets raised. So its a end to end notification.

The extensions I suggested before also send some kind of reply to the message to that you can write a simple wrapper and have a callback as well.

XEP-0198: Stream Management is implemented in MatriX. When your server supports it you could send your message with SendAndAck and define a callback. But stream management is on a different level than the end to end notifications of Iqs or XEP-0184: Message Delivery Receipts.

In XMPP the network infrastructure looks like this:

Cient A <==> Server <==> Client B
or

Cient A <==> Server A <==> Server B <==> Client B

As you can see there are are to 3 hops, on a big clustered server it can be also more with internal network.
You need to decide on which level you need your notifications. The options are:

  • 1) Client Socket level. The stanza left the client socket without errors. Processing can still fail somewhere on the server or the other hops
  • 2) Stream Management Acks, the server received the stanza and handles it properly. Message could still fail on server 2 or client 2
  • 3) End to End notifications, Iqs, message receipts and similar. This guarantees you for 100% that the message was received and handled.

Alex
Avatar
Alex #5
Member since Feb 2003 · 4447 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
if  XEP-0184: Message Delivery Receipts does not meet your requirements exactly you can easily create your own extension for end to end notifications, or send your payloads with IQs instead of messages.

Alex
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: