我试图重建我在 VB.net 的 Github 上找到的C# Persistent Connection Example,但我无法让它工作。
这就是我所做的:
1) 在新的 VB 类中创建一个新的端点
Imports SignalR
Imports System.Threading.Tasks
Public Class MyEndPoint
Inherits PersistentConnection
Protected Overrides Function OnConnectedAsync(request As IRequest, connectionId As String) As System.Threading.Tasks.Task
Return Connection.Broadcast("Connection " + connectionId + " connected")
End Function
End Class
2) 将路由添加到 global.asax 文件中
Public Class Global_asax
Inherits System.Web.HttpApplication
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
RouteTable.Routes.MapConnection(Of MyEndPoint)("echo", "echo/{*operation}")
End Sub
End Class
我有以下调试信息:
'SignalR.RouteExtensions' 中定义的扩展方法'Public Function MapConnection(name As String, url As String, type As System.Type) As System.Web.Routing.RouteBase' 不是通用的(或没有自由类型参数)等不能有类型参数。
知道如何重写这行代码以使其正常工作吗?
RouteTable.Routes.MapConnection(Of MyEndPoint)("echo", "echo/{*operation}")