I am thinking that this API call is highly inefficient and in fact takes way to long to return as it is currently in my SiteMaster (included on top of all of my websites pages.
' get total unread messagecount
Dim UnreadMessageCount = 0
Dim dc As New DataConn(ConfigurationManager.ConnectionStrings("xxxxxxxxxxxxxx").ToString)
Dim errmsg As String = String.Empty
Dim dt As DataTable
Dim strsql = "exec xxxxxxxxxx " & xxxxxxxxxxxxxxx
dt = dc.GetDT(strsql, errmsg, False)
If errmsg.Length = 0 AndAlso dt.Rows.Count > 0 Then
Dim accountSid As String = ConfigurationManager.AppSettings("xxxxxxxxxxxx")
Dim authToken As String = ConfigurationManager.AppSettings("xxxxxxxxxxx")
TwilioClient.Init(accountSid, authToken)
Dim userConversations = UserConversationResource.Read(pathUserSid:=dt.Rows(0)("TwilioSID"))
For Each item In userConversations
Dim Messages = UserConversationResource.Fetch(pathUserSid:=dt.Rows(0)("TwilioSID"), pathConversationSid:=item.ConversationSid)
If Messages.UnreadMessagesCount IsNot Nothing Then
UnreadMessageCount += Messages.UnreadMessagesCount
End If
Next
End If
I program in VB (not C#). I can only see this routine as becoming much worse as the website grows.