botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Refresh frequency for DirectLineClient

Open Sams4u opened this issue 10 years ago • 5 comments

Hi Team,

I notice that in the web chat bot client the refresh frequency by which we are polling the bot is around 500mS. Using the DirectLineClient the same referesh occurs at around 5 seconds. Is there somewhere we can control the frequency at which the DirectLineClient polls the bot for responses? DirectLineClient is a part of the using Microsoft.Bot.Connector.DirectLine Namespace.

Thanks

Sams4u avatar Sep 23 '16 06:09 Sams4u

Hi @Sams4u, there's no polling loop built in to the DirectLineClient. You control the interval in your code.

dandriscoll avatar Sep 23 '16 13:09 dandriscoll

May i know where can i set that. Below is the lines of code i am using. Please suggest

Message message = new Message(conversationId: conversationID, text: messageLocal);
            message.FromProperty = "xyz";
            convs.PostMessage(conversationID, message);          
            response = convs.GetMessages(conversationID, waterMark);

Sams4u avatar Sep 26 '16 06:09 Sams4u

You must put your GetMessages call in a loop. Take a look at the "ReadBotMessagesAsync" method here: https://github.com/Microsoft/BotBuilder-Samples/blob/master/CSharp/core-DirectLine/DirectLineClient/Program.cs

dandriscoll avatar Sep 26 '16 17:09 dandriscoll

I understand the Asynchronous calls with loop you referring to. But here my problem is since its a webform based client application however frequently i make the calls, response cant be updated to the chat UI unless initiated by user event. So once user clicks the send button, call comes to the server and it process the result and send the response back. But if any response comes few seconds after it wont be send to the page asynchronously. So real time communication is not happening. Any suggestion?

Sams4u avatar Sep 29 '16 07:09 Sams4u

Hi @Sams4u, you would need to change your application so the browser can receive updates from the server. A simple webform application is typically not capable of asynchronous chat, no matter what protocol it is using.

dandriscoll avatar Oct 01 '16 18:10 dandriscoll