Source Code Improvement

Last post 10-31-2004, 10:47 AM by cutechat. 1 replies.
Sort Posts: Previous Next
  •  10-30-2004, 3:11 PM 2262

    Source Code Improvement

    In my prevous post, I have discussed the following scenario :


    Suppose the two users Arsh and  Adams have joined the chat and they are chatting for about say 10 - 15 minutes. 

    After that Arsh had left the Chat room and then Adams. This is fine uptil now.


    Now what happens is, When Arsh again logins after about half an hour later, and start chatting, the main chatting area  ( where all the incomming and the outgoing messages are displayed ) , again shows the messages of my previous CONVERSATION with Adams.

     
     
    I have a solution for the above mentioned Problem : (DO THIS AT YOUR OWN RISK)
     
    Open the cutechat_msgs table
     
    Add a new field    "flag"
                           
                                     FIELD NAME                   DATATYPE
                                     --------------------------------------------------------------
                                     flag                                    int
     
    and set its default value to 0.
     
     
    Now every time the user sends a message to another user with which he is chatting, this message is stored in the cutechat_msgs table. All you have to do is Modify the QUERY that is inserting the chat messages into the cutechat_msgs table, and send the value of 0 in the flag field.
     
                    flag == 0 , MEANS this is a new message and it is not displayed yet.
     
    Now, To display messages in to the main chat area  use
     
                   SELECT * FROM cutechat_msgs WHERE flag = 0;
     
    After selecting the messages from table UPDATE flag = 1, Now the flag is changed to 1. This message will never be displayed again in the main chat area where the messages are displayed.
     
     
    in the above text i have written modify the QUERY, ie for simply understanding purposes only. Actually, there are
    SQL Stored procedures with parameters.
     
    You have to modify them with great care, and this can be only done if you are a .NET Professional.
     
     
     
    From; Arshvinder Singh Sehmi.
    Member of Chandigarn .Net Users Group.
    India.
    ThE eNeMy Of My EnEmY iS mY fRiEnD.
     
     
     
     
  •  10-31-2004, 10:47 AM 2276 in reply to 2262

    Re: Source Code Improvement

    Arsh:

       
     
        Thanks for you idea .
     
        I know what it means .
     
        Currently the CuteChat list the message by time .
     
        maybe is 'SELECT  * FROM CUTECHAT_MSGS WHERE DT>=@lastdt"
     
        Each user have their @lastdt , when the user update the messages , they get the message , and set the @lastdt to now .
        After a few seconds , they use the old @lastdt to fetch messages again .
     
        When you re-connect the room  , the @lastdt is set to min-value . so the last messages would be listed .
     
        CuteChat has a configuration property to control that.
     
        <cuteChat historytimeout="10"/> means , when you get in the room, you could see the last messages in 10 minutes .
        (default value is 30 , because more people need to know what the users are chatting in the room)
        if you set the historytimeout to 0 , you would get nothing .
     
    Regards , Terry .
View as RSS news feed in XML