Author Topic: Chat/ Status Menu with php and javascript  (Read 749 times)

Offline AcidicOne

  • Level 16
  • *
  • Posts: 147
  • Reputation: +0/-0
    • View Profile
Chat/ Status Menu with php and javascript
« on: January 31, 2010, 03:25:19 AM »
Okay so I've seen quite a few post's about a chat system, most recommending a framework or something to integrate. I am looking for the name I suppose you would say of the Javascript command's to look up for a very simple say 5 second timer, to pull the chat information from the DB and possible filter using the sesson login from php.

Yes i've googled and looked at quite a few frameworks/chat scripts, but i have no need for something so robust, i simply want a chat with text commands for various msg types ie.. /w username for whispers,/g for guild chat etc

So that being said i suppose i am asking those with javascript experience on what commands i would need to use the users session login to identify them,simple private message use, say check if a user has logged in recently using a timestamp login returning "user not online" or sending the user the private message,check which guild/clan they are a part of and only display the chat that pertains to them.

edit

Almost forgot, and would the same commands be used to create a semi real time stats display ie a module/menu display of a user's stats are updated on the same 5 second basis for accuracy
« Last Edit: January 31, 2010, 03:28:09 AM by AcidicOne »
People Like You, Are the Reason People Like Me Need Medication

Offline jannesiera

  • Level 35
  • **
  • Posts: 1,026
  • Reputation: +6/-1
    • View Profile
    • BBGameDesign
Re: Chat/ Status Menu with php and javascript
« Reply #1 on: January 31, 2010, 05:29:01 AM »
I think I don't really understand your question but I'll try to explain what I know anyway :).

When building a simple chat system you have to go through these steps:

 - On page load check the database for the latest messages and players online and display them.
 - Every X seconds you do an ajax call to run a php script and check the database for new messages and check users online (or you could check users online every X minutes or so, to save some resources).
 - When the players sends a chat message you do an ajax call to a php script to save the message to the database + update the chat

That's it (at least I think that's it :P). You just have to make sure you implement your "special" chat features in the correct place.

For example: if a user sends a private message "/w username blabla" you check the first X characters of the string and if it matches "/w" (or another command like "/g or whatever) you check the username and save it in the correct place in the database. When you display your chat you make sure to check regular, private and guild messages.

You see what I mean? Or do I need to be more specific?

Offline raestlyn

  • Level 29
  • **
  • Posts: 463
  • Reputation: +9/-5
    • View Profile
Re: Chat/ Status Menu with php and javascript
« Reply #2 on: January 31, 2010, 05:04:52 PM »
Settimeout() for ajax call. And the rest is pure php for the callback.. 


I can send you pics of my cocks if you want reference.


Offline AcidicOne

  • Level 16
  • *
  • Posts: 147
  • Reputation: +0/-0
    • View Profile
Re: Chat/ Status Menu with php and javascript
« Reply #3 on: February 01, 2010, 12:24:06 AM »
Thanks,actually got my answer in pm but thanks to all.
People Like You, Are the Reason People Like Me Need Medication

Offline JGadrow

  • Level 35
  • **
  • Posts: 1,133
  • Reputation: +23/-2
    • View Profile
Re: Chat/ Status Menu with php and javascript
« Reply #4 on: February 01, 2010, 10:17:39 AM »
Thanks,actually got my answer in pm but thanks to all.
Awesome. :) If you wouldn't mind sharing that answer as a post to this topic it might help others with similar questions. This is, after all, a community of development. It's better, if an answer exists, that it is posted somewhere. :D
Idiocy - Never underestimate the power of stupid people in large groups.


Offline AcidicOne

  • Level 16
  • *
  • Posts: 147
  • Reputation: +0/-0
    • View Profile
Re: Chat/ Status Menu with php and javascript
« Reply #5 on: February 01, 2010, 05:20:05 PM »
Oh was simply like rast said, what i was looking for was the function do make JS do the pulling from the DB with a timeout. An also a tutorial was linked to me with the breakdown of the code can be found at the following

http://www.dynamicajax.com/fr/AJAX_Driven_Web_Chat-271_290_291.html
People Like You, Are the Reason People Like Me Need Medication

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal