locked
Where to maintain state on server RRS feed

  • Question

  • User-308628221 posted

    Hi,

    I am developing a feature in my app where I need to store the state of a particular series of actions between 2 users, just like an ajax based chat service. 


    Where do I store the state? Or taking the example of Ajax based chat, where should I store what message User1 entered and when Uer1 entered how is it shown to user2?


    I was thinking application object but read it is not recmmended. 

    Wednesday, September 15, 2010 2:46 PM

Answers

  • User1480033891 posted

    Hi,

    It seems there is so much involve in the whole process and you cannot obtain that by simply using session state.

    • You need to track users (whos online and whos offline). Remember each visitor creates a session id, you can log in a database table user in a regular interval (ex. every 60 secs). if the a user has not updated in ex. 5 mins the it is considered offline
    • Create a stored procedure to track online and offline users. This stored procedure will be excuted by an scheduled job.
    • Next maybe is to match users using their session id. Save each message in a table where users can fetch in an interval (say every 60 secs) Once a record is read then it is also deleted.

    Well this is just what I think but it still up to you to implement.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 16, 2010 3:39 PM

All replies

  • User1444430368 posted

    Do you really want a chat system like in a widget that is constantly showing live messages as they come in or some kind of messaging system that only displays a message in a pop-up as you are navigating through the site but only when you refresh the page?

    Wednesday, September 15, 2010 3:21 PM
  • User-308628221 posted

    Do you really want a chat system like in a widget that is constantly showing live messages as they come in or some kind of messaging system that only displays a message in a pop-up as you are navigating through the site but only when you refresh the page?


    Well actually something similar to the first option. It is not really a messaging system, but I gave the analogy of a chat system because it works in a similar manner. The idea is as follows:

    A user can is able to see which other users are online and then challenge one of them. The other user receives the challenge and accepts it. Now both the users are given 5 questions each and the match starts simultaneously for them (almost simultaneously)  Then as a user navigates thru the question or solves it, the state is updated on the other user screen as well. 

    Essentially this is very similar to a chat system like say facebook chat. I am able to see who all are online. I send a chat msg to my friend who can then respond to that and that response is seen on my chat window. 


    I believe all this can be achieved by using ajax. I can easily make ajax calls to .asmx webservices and retrieve objects for a particular user as Session can be accessed there. However, I am wondering where to maintain state because session is for a particular user and I want my particular object to be accessible for two particular users.


    I hope you get the point.  Also, there will hardly be any postbacks, as everything is done using ajax. 


    What do you recommend for such a thing?

    Wednesday, September 15, 2010 11:36 PM
  • User1444430368 posted

    Normally with chat systems you don't have to persist it anywhere, when a message is published you push it to all your subscribers.


    Thursday, September 16, 2010 4:10 AM
  • User1480033891 posted

    Hi,

    It seems there is so much involve in the whole process and you cannot obtain that by simply using session state.

    • You need to track users (whos online and whos offline). Remember each visitor creates a session id, you can log in a database table user in a regular interval (ex. every 60 secs). if the a user has not updated in ex. 5 mins the it is considered offline
    • Create a stored procedure to track online and offline users. This stored procedure will be excuted by an scheduled job.
    • Next maybe is to match users using their session id. Save each message in a table where users can fetch in an interval (say every 60 secs) Once a record is read then it is also deleted.

    Well this is just what I think but it still up to you to implement.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 16, 2010 3:39 PM