proggR Posted March 5, 2010 Share Posted March 5, 2010 I'm trying to create a simple chat script using AJAX. I've been hacking around with code someone published alongside a tutorial and I've been able to figure out how it works in as far as the tutorial covers and a little bit more. What I want to add now though is automatically assigning an id to each user. The id will auto increment with each added user but in the event that a user logs off, the id becomes available again and the next user to log on will get that id. This way users can interact with each other directly without having to type in long misspelled user names. I'm going to keep searching but so far I haven't had much luck. I'm probably Googling the wrong thing but I thought someone here could get me on track. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
mapleleaf Posted March 5, 2010 Share Posted March 5, 2010 Not sure why you need the id to become available again. I assume there is no signing up just allocating ids for the session. Still there will need to be some sort of human readable identifier for those in the chat. Quote Link to comment Share on other sites More sharing options...
proggR Posted March 10, 2010 Author Share Posted March 10, 2010 Not sure why you need the id to become available again. I assume there is no signing up just allocating ids for the session. Still there will need to be some sort of human readable identifier for those in the chat. That's right, there is no signup. Or at least the majority of users wouldn't be signed up. I may offer a signup service to reserve names/ids but that's later. And that's correct as well that ids are just for the session. A similar chat site is teenchat. I like a lot of things about their site but I don't like a bunch and there are features missing that I want to add to a chat as well. Its really just for a project to keep busy. Nothing I'd expect to launch publicly I don't think but who knows. Basically I'm wondering how to handle session only ids within a database. Should I have it all handled by the PHP scripts maybe and have the primary key be for the user name instead. I suppose that would all the difficulties away. How would be a good way to index it in order for the script to find open ids the fastest. I imagine scanning the database for an open id, especially when it wouldn't be organized by that id, will take a little more processing time than I wanted. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.