Signalr 编码Webtest中的信号器持久连接
我在控制台应用程序中有以下代码:Signalr 编码Webtest中的信号器持久连接,signalr,webtest,persistent-connection,Signalr,Webtest,Persistent Connection,我在控制台应用程序中有以下代码: var connection = new Connection("http://localhost/xxx/signalr"); connection.Error += ex => { string msg = string.Format("***SignalR Error: {0}", ex.ToString()); Debug.WriteLine(msg); }; connection.Received += data => {
var connection = new Connection("http://localhost/xxx/signalr");
connection.Error += ex =>
{
string msg = string.Format("***SignalR Error: {0}", ex.ToString());
Debug.WriteLine(msg);
};
connection.Received += data =>
{
string msg = string.Format("***SignalR Received: {0}", data);
Debug.WriteLine(msg);
};
connection.Start().ContinueWith(task =>
{
if (task.IsFaulted)
{
string msg = string.Format("***SignalR Failed to start: {0}", task.Exception.GetBaseException());
Debug.WriteLine(msg);
}
else
{
string msg = string.Format("***SignalR Started: {0}", connection.ConnectionId);
Debug.WriteLine(msg);
connection.Send("Hello");
}
});
调试服务器时,我可以看到调用了OnConnected
和OnReceived
。
如果在编码的WebTest中放置相同的代码,则会调用服务器上的OnConnected
,但服务器上不会接收到connection.Send
问:可以在WebTest中使用SignalR.Net客户端吗
问:在WebTest中使用SignalR持久连接的最佳方式是什么
谢谢