目前,我有一个PHP系统订单与客户端和管理端,客户端作出订单和管理状态根据订单的进展。信息订单存储在MySQL数据库表中。
例如,这是我存储用户帐户、信息顺序和状态顺序的表:
CREATE TABLE order (
idorder INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user VARCHAR(30) NOT NULL,
content_order VARCHAR(30) NOT NULL,
status VARCHAR(50)
);当客户端使用“待定”状态注册订单时,我们在管理页面中检查此订单,并通过AJAX将状态单击按钮更新为“进度”,但客户端必须刷新其页面以查看订单的更改,我希望客户端在其站点中的订单状态发生变化时得到推送通知。
我正在测试Push.js工具,效果很好。就像这个例子:
<html>
<body>
<h4>Press button</h4>
<button id="notify">Notify</button>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/push.js/1.0.4/push.min.js"></script>
<script>
$(document).ready(function(){
if(!Push.Push.Permission.GRANTED){
Push.Permission.request();
}
});
$("#btn_notificar").click(function(){
//Push.Permission.request();
Push.create('NOTIFICATION', {
body: 'My first notification',
icon: 'icon.png',
timeout: 8000, // Timeout before notification closes automatically.
vibrate: [100, 100, 100], // An array of vibration pulses for mobile devices.
onClick: function() {
window.focus();
this.close();
}
});
});
</script>
</body>
</html>当管理员的订单状态发生变化时,我如何将此通知集成到客户端页面中。
我需要一些帮助。
发布于 2017-08-17 19:18:01
这可以通过在用户浏览器和服务器之间建立套接字连接来实现。
拟议流动:
https://stackoverflow.com/questions/45740141
复制相似问题