is PHP suitable for app Instant Messaging service?

Source: Internet
Author: User
Recently want to write a adroid version of the Instant messaging app, just for PHP will be some, want to ask everyone PHP suitable for instant messaging service side? What are the pros and cons?

Reply content:

swoole! Don't explain!! A while ago, I wrote a naked
The PHP section is based on the socket
iOS section is used for Socketrocket
The main thing is that the PHP listening port waits for the client request and handles the request accordingly.
The client follows the connection-login-Send & Receive Message mode to
1, the client requests the connection, the service side gives the connection an index, returns the connection succeeds
2, the client detected a successful connection, send identity information to the server login, if the information is correct, the server will be the account information and connection index binding, return login success
3, the client to an ID account to send chat information, the server will save the chat information to the database, while retrieving whether the recipient has a corresponding connection index, there is a chat message sent, the receiver will hear the message and respond. Push notification if not on the line. The sending of successful messages is also returned to the sender in order to confirm the successful delivery.
Use is able to use, the service side often hang off, later or add a restful backup plan .... Haha, our project is to use the Gatewayworker to write the chat module. After you have implemented an Instant messaging backend, it is estimated that you do not have the desire to write instant messenger apps, and it is absolutely the degree of vomiting that you see.

The PHP Instant Messaging server can be Workerman and is a high-performance PHP socket framework.

On the basis of Workerman, there is a gatewayworker,tcp long-connected application framework to simplify your workload.

But it is also a foundation, and you have to make a lot of things to build your house.

If it's for research, you can write and read.

If your center is making apps, you might as well use these bass services.

For example:
Ring-Instant Messenger cloud leader
Leancloud
There are instant messaging services available, Access SDK tone method can be, concentrate on their own business.

These service providers are free version, the user is basically no charge. In my case with PHP, the feeling polling problem is not big, the database operation will be the bottleneck, I did not do just feel. I used to have a third-party wild dog feeling. Must workerman the Gatewayworker
Supports multi-protocol, distributed deployment, hot update
Examples of documents are very full if you have to ask if you can, the answer is yes. The actual project is not suitable to compare, to see the project resources, to see the selection of the team, but also to see the mood of leadership. You ask, you must have done research such as Java, to their respective advantages have a general understanding.
Based on the experience, my answer is worth trying to use php! Anyway, you write your own, also familiar with, why not let go. PHP should not be able to actively push the message there
A client rotation request is required to detect if there is a new message on the server side and then server-side response so the app needs a timed request for server time the trade-offs are not good, the price is too high the new message is not timely
can use a generic Java socket can be sent UDP packet native socket a few lines of code is enough to specify the address specified port background run a service listening port server side write the corresponding acceptance
Nodejs to socket already encapsulated communication better written
There may be some mistakes in my answer. I have done these wrong places welcome everyone to correct the right to do, do not come out is not appropriate, some things, you do not, I do not do, no one, to know, you and I are not a spectator, but the participants of the Times absolutely can, and very reliable. Recently used PHP to do two chat items, one is the app, one is H5. I used the Workerman chat case rewrite, the document is very full, the case is also more.
  • 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.