开发者

Get realtime updates from database into ajax based asp.net web page from sql server database.. like facebook

开发者 https://www.devze.com 2023-04-06 16:03 出处:网络
I am trying to solve a problem. I have a asp.net repeater that shows a User friends that are obtain from sql server database with their statuses.

I am trying to solve a problem. I have a asp.net repeater that shows a User friends that are obtain from sql server database with their statuses.

Some of the friends could be online and some of them could be offline at the time of getting results from database and i mark then offline/online. Now i need a mechanism when the user in the list goes online or offline, i should update the status of the friends in the repeater. 2

The only idea i got is to put timer and call the stored procedure to get friends list after every 10 seconds to check their statues but this mechanism has 2 BIG problems

1- Too many database calls against 1 user (1 DB call every 10 sec or so) .. just imagine if the site has 10000 users i cant use this technique. 2 -This technique is slow as well, as i have to get results and loop through every user in the repeater and check/ update his/ her status...... ust imagine if the site has 10000 users

i have seen in Facebook like they do this on real-time bases and i want almost similar kind of mechanism ... how can i do this??? any code or tutorial from .net point of view开发者_C百科 will be appreciated


You could do a sqldependency which would "tigger" when a row is updated instead of pounding the database over and over again. A push system instead of a pull system. But with that said, to read with (nolock) is not expensive at all if the tables are indexed well and their stats up to date.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldependency.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消