使用方法を理解するためだけに、 SignalRを使用して単純な Web アプリケーションを開発しました。私が使用したクラス::
public class HealthCheck : Hub
{
public static List<string> messages = new List<string>();
public void GetServiceState()
{
Clients.updateMessages(messages);
}
public void UpdateServiceState()
{
messages.Add(DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"));
Clients.updateMessages(messages);
}
}
次に、私が使用したWebページ::
<script type="text/javascript">
$(function () {
// creates a proxy to the health check hub
var healthCheckHub = $.connection.healthCheck;
// handles the callback sent from the server
healthCheckHub.updateMessages = function (data) {
$("li").remove();
$.each(data, function () {
$('#messages').append('<li>' + this + '</li>');
});
};
$("#trigger").click(function () {
healthCheckHub.updateServiceState();
});
// Start the connection and request current state
$.connection.hub.start(function () {
healthCheckHub.getServiceState();
});
});
</script>
<ul id="messages">
</ul>
<button type="button" id="trigger">
Send request</button>
私の問題は、ボタンをクリックすると、結果が表示されるまでに約40秒または1分かかるということです...
FF または IE9 では、結果がすぐに得られます。
私のコード、signalR、またはブラウザの問題です。私はSignalR V 0.5.3を使用しています
ご協力いただきありがとうございます。