Re: Re: build a multi chat server with php
| From: | Nathan Rixham | Date: | Sat, 08 Dec 2007 18:35:11 +0000 |
| Subject: | Re: Re: build a multi chat server with php | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265585@lists.php.net to get a copy of this message | ||
Robert, Abderrazzak,
You make some good points, and apologies abderrazzak; I woke under stress and haven't been the friendliest today!
The Ajax method is definately a good approach, particulary if you're wanting to have the chat client within a web page.
The other approach is to make a php chat daemon, this can be achieved by running php through the CLI. To get started some reading of the PHP Manual would be advised, partculary under stream_socket_server, stream_socket_accept, pcntl_fork, the CLI section itself, and finally some catching up on php wrapeprs to stdin, stdout and stderr - stream_socket_pair may come in useful aswell.
I'd strongly recommend you follow Roberts advice to start with, and build that chat application as a standrd php app with mysql and an ajax front end (perhaps even an iframe whilst developing functionality, then upgrade to ajax).
Many Regards
Nathan
Robert Cummings wrote:
On Sat, 2007-12-08 at 12:19 -0500, Robert Cummings wrote:On Sat, 2007-12-08 at 16:46 +0000, Nathan Rixham wrote:Should have been:1 - yes you can make a multichat daemon in php 2 - if you don't know that it's possible or where to begin, then odds are you won't be able to make it.That's what the list is for... to help him find his way.abderrazzak nejeoui wrote:There are two approaches. You either are looking to do it as a standalone application outside of the web environment, or you are looking to do it via the web environment using some combination of backend PHP and front end browser refreshes (not recommended) or AJAX. A simple scenario for the web version follows:Hello, i want build a multi chat server based in php. 1- is that possible 2- if yes can you instruct me how to bigin thanks1. User logs in (or implicitly is logged in anonymously) 2. User sees any ongoing discussion for X amount of previous time 3. User can post a form to the website (or post data via AJAX) which effectively is the user's message to the chat server 4. Message is save to database with ID/timestamp 5. Browser refreshes or AJAX retrieves messages greater than user's session message ID 6. Return to step 1.6. Return to step 3.Cheers, Rob.