Source Code Improvement

  •  10-30-2004, 3:11 PM

    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.
     
     
     
     
View Complete Thread