在显示消息流时,SignalR客户端方法不是每次都执行。 [英] SignalR client method is not executing everytime while displaying a stream of messages.

查看:102
本文介绍了在显示消息流时,SignalR客户端方法不是每次都执行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I need to display a stream of message. The client method DisplayMessage is not executing everytime. But when I put debugger in the client code, it executes everytime. Here is my client code.

        chat.client.displayMessage = function (data) {
        // Html encode display data
        debugger;

        var encodedData = $('<div />').text(data.GPSPosition).html();
        $('#discussion').append('<li>' + encodedData + '</li>');

}

how can i display a stream of messages? Why it is only working with debugger?

Here is my server code. I am calling client method from a class outside the hub class.

        IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<AzureGuidanceEventHubReceiver>();
       hubContext.Clients.All.DisplayMessage(newData);

推荐答案

('< div / > ')。text(data.GPSPosition).html();
('<div />').text(data.GPSPosition).html();


('#discussion ')。append('< li > '+ encodedData +'< / li > ');

}

如何显示消息流?为什么它只与调试器一起使用?

这是我的服务器代码。我从集线器类之外的类调用客户端方法。

IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext < AzureGuidanceEventHubReceiver > ();
hubContext.Clients.All.DisplayMessage(newData);
('#discussion').append('<li>' + encodedData + '</li>'); } how can i display a stream of messages? Why it is only working with debugger? Here is my server code. I am calling client method from a class outside the hub class. IHubContext hubContext = GlobalHost.ConnectionManager.GetHubContext<AzureGuidanceEventHubReceiver>(); hubContext.Clients.All.DisplayMessage(newData);


这篇关于在显示消息流时,SignalR客户端方法不是每次都执行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆