Welcome Guest, Not a member yet? Register   Sign In
Track users in an chat system
#11

[eluser]SEWilco[/eluser]
You could look at the code and techniques used in ARSC, a web chat program. It is using pinging and does time out users eventually, although the online demo site is configured with a long timeout. http://www.reallysimplechat.org/

Notice that the server can't even detect a disconnection when using an open TCP/IP socket interface, because the network layer retries for a while before it decides that the remote computer is not going to respond.
#12

[eluser]Fabdrol[/eluser]
Right now I'm combining the users request to check for new messages, with a time-out check. Every 30 seconds the user sends one, empty, GET request to the server, and the server then updates the time of the 'last ping'.
Since the client-side of the app checks the server every second for new messages since the last one, it also checks if the user on the other side hasn't timed out yet. Having in mind that a client won't be making periodic ping's to the server, when the browser is closed or at another site/page. If I want I can easily extend this behaviour to the rest of the site, if i'd want to grant the user the possibility to browse the site while in a chat.

For speed and security reasons, all states and communication is done via a database, although it would be faster to use the file system. Thing is, it's absolutely necessery that the chats are secure, and won't leak out, so I chose for the database.

@cold_fusion: I'll release the code when it's matured, or at least a modified version. Right now it's too much in beta to be released, but if you drop me an email I can send you the link to play around with it, to see if it fits your requirements.
#13

[eluser]Cro_Crx[/eluser]
[quote author="Fabdrol" date="1262631689"]although it would be faster to use the file system.[/quote]

That's not necessarily true. The database you're using will be utilizing the same disk as the file system. The database will be specialized to work extremely quickly for small amounts of data.
#14

[eluser]SEWilco[/eluser]
[quote author="Fabdrol" date="1262631689"]
For speed and security reasons, all states and communication is done via a database, although it would be faster to use the file system. Thing is, it's absolutely necessery that the chats are secure, and won't leak out, so I chose for the database.
[/quote]

A file system is a database for files. But a database is probably a better tool for this, particularly as you'll have to do things such as search for all users who haven't responded recently... or find an inactive user's info so you can resurrect their connection when their broadband laptop comes out of the train tunnel after five minutes.
#15

[eluser]SEWilco[/eluser]
Oh, I just noticed this is a one-on-one chat application. If the user interface is like a phone conversation, that reduces the need to recover a connection. If the user interface uses separate windows for a half-dozen friends, then automatic reconnections would be nice.
#16

[eluser]Fabdrol[/eluser]
@SEWilco, Yeah, I extended it today so it has functionality for that. But we'll keep a distinction in features for registered users and 'guest'-users.
I wrote the system completely scalable and very flexible, so it's able to house multi-user chats as well, if I ever need it!

Cheers,
FAbian!
#17

[eluser]gigas10[/eluser]
Quote:imagine you are chatting with your aunt, and your aunt’s dog is on fire. So she shuts down her old Commodor 64 ‘internet-ready edition’ to get a gun to stop the dog from suffering. But the moment she disconnects, you want to know you can stop telling her about the disastrous date you had last night, since she aint listening anymore.

o_0
#18

[eluser]Fabdrol[/eluser]
[quote author="gigas10" date="1262998917"]
Quote:imagine you are chatting with your aunt, and your aunt’s dog is on fire. So she shuts down her old Commodor 64 ‘internet-ready edition’ to get a gun to stop the dog from suffering. But the moment she disconnects, you want to know you can stop telling her about the disastrous date you had last night, since she aint listening anymore.

o_0[/quote]

Yeah, I'm sorry. I was in a weird mood Tongue




Theme © iAndrew 2016 - Forum software by © MyBB