Table of Contents
回复内容:
Home Backend Development PHP Tutorial PHP适合做app即时通讯的服务端吗?

PHP适合做app即时通讯的服务端吗?

Jun 17, 2016 am 08:31 AM
app php

最近想写一个Adroid版的即时通讯app,刚好对PHP也会一些,想问下大家PHP适合做即时通讯的服务端吗?有什么优劣之处吗?

回复内容:

swoole!不用解释!! 前段时间裸写了一个
PHP部分基于Socket
iOS部分是用的SocketRocket
主要就是PHP监听端口等待客户端请求,并对请求做出相应的处理
客户端则按照连接-登录-发送&接收消息的模式来
1、客户端请求连接,服务端给予该连接一个index,返回连接成功
2、客户端检测到连接成功后,发送身份信息到服务端登录,若是信息正确,服务端将该账号信息与连接index绑定,返回登录成功
3、客户端对某一id账号发送聊天信息,服务端将该聊天信息保存到数据库,同时检索该接收方是否有与之对应的连接index,有则发送聊天信息,接收方会监听到该信息并响应。如果不在线则push notification。同时也会返回发送成功的信息给发送方,以便确认发送成功。
用是能用,服务端经常挂掉,后来还是加RESTful后备方案。。。。 哈哈,我们项目上就是用的GatewayWorker写的聊天模块。 等你实现了一个即时通讯的后端后,估计你也没欲望写即时通讯的app了,绝对是看见就吐的程度。

php即时通讯服务端可以采用workerman,是一个高性能的php socket服务器框架。

在workerman 的基础上又有GatewayWorker,TCP长连接的应用框架,简化你的工作量。

不过也就是个地基,还要你自己实现一大堆东西来建房子。

如果是为了研究的话,可以写写看。

如果你的中心是做出app来,还不如用这些bass服务。

例如:
环信-即时通讯云领导者
LeanCloud
都有即时通讯服务提供,接入SDK调调方法就可以了,专心于自己的业务。

这些服务商都是有免费版本的,用户少的话基本上不用收费。 以我用php的情况来看,感觉轮询问题不大,数据库操作会是瓶颈,我没做过只是觉得。我用第三方野狗做过感觉 还可以。 必须workerman的GatewayWorker
支持多协议、分布式部署、热更新
例子文档非常全 如果你要问能不能,答案是能。实际项目中合不合适要对比,要看项目资源,要看团队的选型,还要看领导的心情。你这么问,想必你肯定做过调研比如java,对它们各自的优势有大致了解。
根据的经验,我的答案是值得尝试使用php!反正是你自己写,也熟悉的,何不放开撸。 php在消息主动推送那里应该不行
需要客户端轮训询请求 检测是否有新的消息 请求服务器端 然后服务器端响应 因此app需要定时请求服务器 时间的取舍不好做 短了代价太高 长了新消息不及时
可以用一般的java socket就可以 发送udp包 原生socket几句代码就够了 指定地址 指定端口 后台跑一个service监听端口 服务器端写好相应的接受收
nodejs 对socket已经封装了 通信更好写
我的回答可能还有一些错误 自己做过这些 不对的地方欢迎大家指正 做出来了就合适,做不出来就不合适,有些事情吧,你不去做,我不去做,就没人了,要知道,你我都不是个看客,而是时代的参与者 绝对可以,而且很靠谱。最近使用PHP做了两个聊天的项目,一个是APP,一个是H5。我用的是workerman的chat案例改写的,文档很充分,案例也比较多。
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

Steps and precautions for registering a Hong Kong Apple ID (enjoy the unique advantages of the Hong Kong Apple Store) Steps and precautions for registering a Hong Kong Apple ID (enjoy the unique advantages of the Hong Kong Apple Store) Sep 02, 2024 pm 03:47 PM

Apple's products and services have always been loved by users around the world. Registering a Hong Kong Apple ID will bring more convenience and privileges to users. Let’s take a look at the steps to register a Hong Kong Apple ID and what you need to pay attention to. How to register a Hong Kong Apple ID When using Apple devices, many applications and functions require using Apple ID to log in. If you want to download applications from Hong Kong or enjoy the preferential content of the Hong Kong AppStore, it is very necessary to register a Hong Kong Apple ID. This article will detail the steps on how to register a Hong Kong Apple ID and what you need to pay attention to. Steps: Select language and region: Find the "Settings" option on your Apple device and enter

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

See all articles