我试图重建我在VB.net上在Github上找到的C# Persistent Connection Example,但我无法让它工作。
这就是我所做的:
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
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
我有以下调试信息:
扩展方法'公共函数MapConnection(名称为String,url为String,类型为System.Type)因为'SignalR.RouteExtensions'中定义的System.Web.Routing.RouteBase'不是通用的(或者没有自由类型参数) )所以不能有类型参数。
知道如何重写这行代码才能使其正常工作吗?
RouteTable.Routes.MapConnection(Of MyEndPoint)("echo", "echo/{*operation}")
答案 0 :(得分:1)
我能够通过使用MapConnection扩展方法的非泛型重载来使代码工作:
RouteTable.Routes.MapConnection("echo", "echo/{*operation}", GetType(MyEndpoint))
希望这会让你前进。