Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Matrix vNext: How to Subscribe for New Voice Call
dotnetnerd #1
Member since Apr 2020 · 5 posts
Group memberships: Members
Show profile · Link to this post
Subject: Matrix vNext: How to Subscribe for New Voice Call
Hi,

I am using Matrix vNext: How do I Subscribe to get Notification for new Call?  I Subscribed for /User/{AgentId}, /User/{AgentId}/Dialogs - still dont get any event on incoming call or status of change in Cisco Finesse Agent Desktop.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Here in the docs it is described how to subscribe to stanzas:
https://dev.matrix-xmpp.io/docs/receiving-messages/

When you post a XML snippet here with a sample of the stanza you are expecting I can help you to build the query.
dotnetnerd #3
Member since Apr 2020 · 5 posts
Group memberships: Members
Show profile · Link to this post
Thank You for quick reply. Do i need to build stanza for incoming call? I am new to Matrix vNext Stuff.  In .NET Framework Version, we just had to have subscribe and register a handler on OnMessage. I did not build any explicit handler.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
All protocol classes fro MatriX exist also in Matrix vNext.

You can listen to all messages just with this code:
  1. xmppClient
  2.     .XmppXElementStreamObserver
  3.     .Where(el => el is Message)
  4.     .Subscribe(el =>
  5.     {
  6.         // handle the message here
  7.         Debug.WriteLine(el.ToString());
  8.     });

but you can be more specific and adjust the Where query to only include your call messages.
But I cannot help you with that until to post a sample call message here.

Alex
humba #5
Member since Feb 2020 · 23 posts
Group memberships: Members
Show profile · Link to this post
I've used the old and now vNext for Finesse.
With what Alex provided above, you have el, which is of type Message (Matrix.Xmpp.Client.Message).

This is how I process the various notifications that arrive through messages

  1. void IFinesseHandler.HandleXmppMessage(Message e)
  2.         {
  3.             try
  4.             {
  5.                 Notification not = e.Value.XmlDeserializeFromString<Notification>();
  6.                 if (e.Value.Contains("apiErrors"))
  7.                 {
  8.                     Notification<ErrorData> errorData = e.Value.XmlDeserializeFromString<Notification<ErrorData>>();
  9.                     CiscoRestApi.Objects.ListOfApiErrors errors = errorData.Data.Data;
  10.                     OnErrorNotification(new ErrorNotificationEventArgs
  11.                     {
  12.                         Errors = errorData.Data.Data,
  13.                         Notification = errorData
  14.                     });
  15.                 }
  16.                 else
  17.                 {
  18.                     switch (not.ObjectType)
  19.                     {
  20.                         case ObjectType.User:
  21.                             Notification<UserData> usrData = e.Value.XmlDeserializeFromString<Notification<UserData>>();
  22.                             OnUserNotification(new UserNotificationEventArgs
  23.                             {
  24.                                 Notification = usrData,
  25.                                 User = usrData.Data.Data
  26.                             });
  27.                             break;
  28.                         case ObjectType.Queue:
  29.                             Notification<QueueData> queueData = e.Value.XmlDeserializeFromString<Notification<QueueData>>();
  30.                             OnQueueNotification(new QueueNotificationEventArgs
  31.                             {
  32.                                 Notification = queueData,
  33.                                 Queue = queueData.Data.Data
  34.                             });
  35.                             break;
  36.                         case ObjectType.Team:
  37.                             Notification<TeamData> teamData = e.Value.XmlDeserializeFromString<Notification<TeamData>>();
  38.                             OnTeamNotification(new TeamNotificationEventArgs
  39.                             {
  40.                                 Notification = teamData,
  41.                                 Team = teamData.Data.Data
  42.                             });
  43.                             break;
  44.                         case ObjectType.Dialog:
  45.                             Notification<DialogData> dialogData = e.Value.XmlDeserializeFromString<Notification<DialogData>>();
  46.                             OnDialogNotification(new DialogNotificationEventargs
  47.                             {
  48.                                 Notification = dialogData,
  49.                                 Dialog = dialogData.Data.Data
  50.                             });
  51.                             break;
  52.                         case ObjectType.UserDialog:
  53.                             Notification<DialogsData> dialogsData = e.Value.XmlDeserializeFromString<Notification<DialogsData>>();
  54.                             OnUserDialogNotification(new UserDialogNotificationEventArgs
  55.                             {
  56.                                 Notification = dialogsData,
  57.                                 Dialogs = dialogsData.Data.Data
  58.                             });
  59.                             break;
  60.                         case ObjectType.UserQueue:
  61.                             Notification<QueuesData> queueDatas = e.Value.XmlDeserializeFromString<Notification<QueuesData>>();
  62.                             OnUserQueueNotification(new UserQueueNotificationEventArgs
  63.                             {
  64.                                 Notification = queueDatas,
  65.                                 Queues = queueDatas.Data.Data
  66.                             });
  67.                             break;
  68.                         case ObjectType.SystemInfo:
  69.                             Notification<SystemInfoData> sysInfoData = e.Value.XmlDeserializeFromString<Notification<SystemInfoData>>();
  70.                             OnSystemInfoNotification(new SystemInfoNotificationEventArgs
  71.                             {
  72.                                 Notification = sysInfoData,
  73.                                 SystemInfo = sysInfoData.Data.Data
  74.                             });
  75.                             break;
  76.                     }
  77.                 }
  78.             }
  79.             catch (Exception x)
  80.             {
  81.                 Log($"Exception processing message {e.Value}: {x.Message}", 2);
  82.             }
  83.         }

The code for the old matrix, looks pretty much the same

  1. private void XmppClient_OnMessage(object sender, MessageEventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 Notification not = e.Message.Value.XmlDeserializeFromString<Notification>();
  6.                 if (e.Message.Value.Contains("apiErrors"))
  7.                 {
  8.                     Notification<ErrorData> errorData = e.Message.Value.XmlDeserializeFromString<Notification<ErrorData>>();
  9.                     CiscoRestApi.Objects.ListOfApiErrors errors = errorData.Data.Data;
  10.                     OnErrorNotification(new ErrorNotificationEventArgs
  11.                     {
  12.                         Errors = errorData.Data.Data,
  13.                         Notification = errorData
  14.                     });
  15.                 }
  16.                 else
  17.                 {
  18.                     switch (not.ObjectType)
  19.                     {
  20.                         case ObjectType.User:
  21.                             Notification<UserData> usrData = e.Message.Value.XmlDeserializeFromString<Notification<UserData>>();
  22.                             OnUserNotification(new UserNotificationEventArgs
  23.                             {
  24.                                 Notification = usrData,
  25.                                 User = usrData.Data.Data
  26.                             });
  27.                             break;
  28.                         case ObjectType.Queue:
  29.                             Notification<QueueData> queueData = e.Message.Value.XmlDeserializeFromString<Notification<QueueData>>();
  30.                             OnQueueNotification(new QueueNotificationEventArgs
  31.                             {
  32.                                 Notification = queueData,
  33.                                 Queue = queueData.Data.Data
  34.                             });
  35.                             break;
  36.                         case ObjectType.Team:
  37.                             Notification<TeamData> teamData = e.Message.Value.XmlDeserializeFromString<Notification<TeamData>>();
  38.                             OnTeamNotification(new TeamNotificationEventArgs
  39.                             {
  40.                                 Notification = teamData,
  41.                                 Team = teamData.Data.Data
  42.                             });
  43.                             break;
  44.                         case ObjectType.Dialog:
  45.                             Notification<DialogData> dialogData = e.Message.Value.XmlDeserializeFromString<Notification<DialogData>>();
  46.                             OnDialogNotification(new DialogNotificationEventargs
  47.                             {
  48.                                 Notification = dialogData,
  49.                                 Dialog = dialogData.Data.Data
  50.                             });
  51.                             break;
  52.                         case ObjectType.UserDialog:
  53.                             Notification<DialogsData> dialogsData = e.Message.Value.XmlDeserializeFromString<Notification<DialogsData>>();
  54.                             OnUserDialogNotification(new UserDialogNotificationEventArgs
  55.                             {
  56.                                 Notification = dialogsData,
  57.                                 Dialogs = dialogsData.Data.Data
  58.                             });
  59.                             break;
  60.                         case ObjectType.UserQueue:
  61.                             Notification<QueuesData> queueDatas = e.Message.Value.XmlDeserializeFromString<Notification<QueuesData>>();
  62.                             OnUserQueueNotification(new UserQueueNotificationEventArgs
  63.                             {
  64.                                 Notification = queueDatas,
  65.                                 Queues = queueDatas.Data.Data
  66.                             });
  67.                             break;
  68.                         case ObjectType.SystemInfo:
  69.                             Notification<SystemInfoData> sysInfoData = e.Message.Value.XmlDeserializeFromString<Notification<SystemInfoData>>();
  70.                             OnSystemInfoNotification(new SystemInfoNotificationEventArgs
  71.                             {
  72.                                 Notification = sysInfoData,
  73.                                 SystemInfo = sysInfoData.Data.Data
  74.                             });
  75.                             break;
  76.                     }
  77.                 }
  78.             }
  79.             catch (Exception x)
  80.             {
  81.                 Log($"Exception processing message {e.Message.Value}: {x.Message} at {e.State}", 2);
  82.             }
  83.         }

The new one is just your regular method taking a Message object, the old one was an event handler. Not really much difference..
This post was edited on 2021-04-03, 18:27 by 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: