Php Development customer service system source code (persistent connection + round robin + reverse ajax)

Source: Internet
Author: User
: This article mainly introduces the php Development customer service system source code (persistent connection + round robin + reverse ajax). If you are interested in PHP tutorials, refer to it. Details: http://www.phpyan.com/home/article/350.html There are two implementation methods: I. iframe + server push technology comet (reverse ajax, that is, the server pushes data to the browser) II. ajax persistent connection + long polling The customer service adopts the first method: iframe + server push technology Ideas: 1: Create a new comentbyiframe. php file. use while (true) to keep connecting to the server. If new data is found during the while process, use ob_flush to push the data to the apache server. use flush to push the data to the browser. 2: Create an html page and insert an iframe. The src of the iframe is comentbyiframe. php. And hide iframe. The data obtained by comentbyiframe. php is output to a function in the parent window using js. this function appends information to the specified chat window. 3: as long as the client receives the data sent from the user, it is displayed as "xx says to you...". the customer service only needs to click the user name. You can send data to this user. The client adopts the second method: ajax persistent connection + long polling Ajax persistent connection: after the file is loaded (or at other times), use ajax to request a php file The requested php file uses the while (true) loop. it does not return data to apache for a long time. Round Robin refers to waiting until the server has no data. when the server has data, it will be returned to the client. In this way, an HTTP request is completed after the request and response. the request is not complete. the client receives the data and requests the data to the server. this is the round robin. It's like a beggar. if you don't give him money, he will keep following you. after you give him money, he will not be satisfied yet and come to ask you again. Implementation ideas: After entering the user end, if there is no user name, use setcookie to set a user name, and then use the ajax persistent connection to keep asking for data from the server (that is, the record that the customer service sends to the user)

The above introduces the php Development customer service system source code (persistent connection + round robin + reverse ajax), including the content, hope to be helpful to friends interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.