Hi friends,
I have been in a doubt for almost a week as I used chating functionality to my web app using signalR2.1.2 and installed it by PM>Install-Package Microsoft.AspNet.SignalR -version 2.1.2 and referenced inside web page as
<script src="~/Scripts/jquery.signalR-2.1.2.js"></script>
<script src="~/Scripts/jquery.signalR-2.1.2.min.js"></script>
<script src="~/Scripts/json2.min.js" type="text/javascript"></script>
<script src="~/Scripts/json2.js" type="text/javascript"></script>
<script src="~/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
try {
$.connection.hub.start();
var myHub = $.connection.Hubupdatedb;
alert('hub connected.');
}
catch (e) { alert('Error: ' + e.message); }
});
myHub.client.AllcurrentUsers = function (allusers) {
alert('Values from hub is got..')'
}
</script>
Startup Class
<Assembly: OwinStartup(GetType(HubForClients.Startup))>
Namespace HubForClients
Public Class Startup
Public Sub Configuration(ByVal app As IAppBuilder)
app.MapSignalR()
End Sub
End Class
End Namespace
Hub Class
Namespace HubForClients
<hubname("hubupdatedb")>
Public Class HubClass
Inherits Hub
Public Shared sCurrentClient As String
Public Shared objcursers As New List(Of CurrentUsers)()
Sub finddata(ByVal sCtrlID As String, ByVal sDatavalue As String, ByVal Noteid As String, ByVal CtrlType As String)
Try
Dim objdb As DB = New DB(Nothing)
If Noteid <> "0" Then
Clients.Group(Noteid).connectClients(sCtrlID, sDatavalue, CtrlType)
End If
Catch ex As Exception
End Try
End Sub
Public Overrides Function OnConnected() As Task
Dim objupdatedb As UpdateDB = New UpdateDB()
Try
sCurrentClient = objupdatedb.GetSession()
If sCurrentClient <> "0" Then
Groups.Add(Context.ConnectionId, sCurrentClient)
End If
Catch ex As Exception
End Try
''''''''''Add current user to a list.''''''''''''''''''''''''''''''''
If objcursers.Count >= 0 Then
Dim sStaffid As String = objupdatedb.GetStaffid()
Dim sStaffname As String = objupdatedb.GetStaffname()
objcursers.Add(New CurrentUsers With {.sCurrentusername = sStaffname, .sCurrentuserid = sStaffid, .sCurrentpatid = sCurrentClient})
End If
Return MyBase.OnConnected()
End Function
Public Function GetUsersList(ByVal sPnoteid As String) As String()
Dim curusers As List(Of CurrentUsers)
Dim ss As String()
Try
curusers = From listuser In objcursers Where listuser.sCurrentpatid = sPnoteid Select New CurrentUsers(listuser.CurName, listuser.Curid, listuser.Curpid) Distinct.ToList()
'Dim curusers1
'Dim averageValue = (objcursers.Where(Function(num) num.sCurrentpatid = sPnoteid)).Distinct()
Dim j As Integer = 0
ss = New String(curusers.Count) {}
For Each i As CurrentUsers In curusers
If Not ss.Contains(i.sCurrentusername) Then
ss(j) = i.sCurrentusername
j = j + 1
End If
Next
Catch ex As Exception
End Try
Return ss
End Function
End Class
End Namespace
but it
throws exception as Unable to get value of the property 'hub': object is null or undefined anybody pls help me.. would be great help for me... thanks in advance...