0

in chat application ,, Two friends x, y (used the same device) x Send to y message then stored in database x make log-out of the application and y log-in application and open chat and received the message here the message stored twice on the local storage and this is problem how to prevent duplicate storage on local storage ?

3
Contributors
4
Replies
23
Views
3 Years
Discussion Span
Last Post by aseel.jaradat.9
1

Each user has a specific, unique, identifier, yes?

Pre-pend your root object with that decorator.

Ex:

UserData:{foo:1};

Can instead be:

1331UserData:{foo:1};

Then your code can look for said data by something like:

localStorage[userID + "UserData"];

Mind you this is all pseudo code so you'll still have to do some work.

Happy coding!!

0

Thank you for your reply, it's really helpful.
But could you please explain it more?
It's not clear for me how i can implement it,on insertion of data or retrieval from storage?, (in android)

thank you.‏

1

i think it is a database problem..i hope the following table will handle the problem you're facing

'msg_table'
msg_id
msg
from
to
seen
msg_sent_time
msg_recv_time

when X sends msg to Y

msg_id    msg    sender   receiver    seen    msg_sent_time    msg_recv_time
    1     hi Y     X          Y        N         3.00 PM           null

when X logs out and Y logs in, display all new messages whose receiver is Y using the following query

SELECT * FROM `msg_table` WHERE receiver = 'Y' AND seen = 'N'

then for each new message seen by Y, update the seen status to Y

UPDATE `msg_table` SET seen='Y' WHERE msg_id = msg_id_from_previous_select

then, the table will look like this

msg_id    msg    sender   receiver    seen    msg_sent_time    msg_recv_time
    1     hi Y     X          Y        Y         3.00PM           3.05 PM
0

Thank you so much for your help, all I have to do now is tackle the coding. . Thank you

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.