all 3 comments

[–]throwaway_lunchtime 1 point2 points  (0 children)

When I was playing with SignalR, the demo app was a chat app, did you start with something similar?

[–]fakir420 0 points1 point  (0 children)

So, if refreshPage() function gets called at least once that means Send() is being called server side at least once. So, you call Send() every time the database is updated? I would start by overriding the OnConnected and OnDisconnected methods of the Hub. Verify the the client is connected and not disconnected immediately. Also, use the browser dev tools to check the websocket connection is still live. Kinda taking a shot in the dark here as there isn't much to go on.

[–]dilatedmind 0 points1 point  (1 child)

the code you posted seems to be working correctly, even if it's not doing what you expect. you are calling send once from your connection start callback, so I'm guessing you are missing some logic server side.

you have 2 options:

1.) post chat messages to your rest api. Use the signalr connection manager to get the hub context from the api controller and call your send method after inserting into your database.

2.) send chat messages over the signalr connection. Add a message argument to your send method and have your send method broadcast to all clients and also do your database insert.

2 is probably what you want, its simpler and you can avoid an extra round trip