实时功能与PHP [英] Real Time Functionlity with php

查看:53
本文介绍了实时功能与PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究考勤系统,项目管理系统也在客户端使用Javascript\Jquery,在服务器端使用PHP \ MySQL处理。



A我的网络应用中的功能是管理员用户消息为此,我已经应用了一个由setTimeout函数(每15秒后)生成的ajax请求来检查数据库中是否有新消息,如果是,则将其返回给管理员。



它工作正常,但缺点是(如你所知)对服务器的连续请求哪个真的很差和坏。据我所知,实时功能可以解决这个问题我已经检查了一些链接 websocket.io和signlR 但是适用于 Nodejs和asp.net

那么,我怎么能用php应用实时功能,或者我得到新数据已经到达数据库而没有继续使用ajax请求。

解决方案

为什么每十五秒一次?需要通知谁有一个约束?



如果你真的需要立即通知 - 为什么不能使用与MySQL调用插入/更新记录相同的代码发送电子邮件通知(如果你需要的话还带有时间戳?这将是实时的,但只有当事件真正发生时才会发生。




I am working on attendance system where project management system is also handling using Javascript\Jquery at client side and PHP\MySQL at server side.

A feature in my web app is user message to admin. For this I have applied an ajax request which is made by setTimeout function (after every 15 seconds) to check that is there any new message comes in database if yes then return it to the admin.

It working fine but the drawback is (as you know) continuous request to server which really poor and bad. As I know that real time functionality can solve this problem I have checked some link websocket.io and signlR but there are applicable with Nodejs and asp.net.
So, how can I apply real time functionality with php or I get that new data have reached in to database without continues request with ajax.

解决方案

Why every fifteen seconds ? Who needs to be notified that fine a constraint?

If you really need immediate notifications - why not have the same code that does the MySQL calls to insert/update a record send an email notification, as well (with a time stamp if you need one? This would then be real time but only when an event actually occurs.


这篇关于实时功能与PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆