<i id='75nwu'><tr id='75nwu'><dt id='75nwu'><q id='75nwu'><span id='75nwu'><b id='75nwu'><form id='75nwu'><ins id='75nwu'></ins><ul id='75nwu'></ul><sub id='75nwu'></sub></form><legend id='75nwu'></legend><bdo id='75nwu'><pre id='75nwu'><center id='75nwu'></center></pre></bdo></b><th id='75nwu'></th></span></q></dt></tr></i><div id='75nwu'><tfoot id='75nwu'></tfoot><dl id='75nwu'><fieldset id='75nwu'></fieldset></dl></div>
    <bdo id='75nwu'></bdo><ul id='75nwu'></ul>
  • <legend id='75nwu'><style id='75nwu'><dir id='75nwu'><q id='75nwu'></q></dir></style></legend>
    1. <small id='75nwu'></small><noframes id='75nwu'>

      <tfoot id='75nwu'></tfoot>

      1. 从 Web 服务器到客户端 bower 的实时通知

        时间:2023-10-10
          <bdo id='OKiRl'></bdo><ul id='OKiRl'></ul>

            1. <tfoot id='OKiRl'></tfoot>

              <small id='OKiRl'></small><noframes id='OKiRl'>

                <tbody id='OKiRl'></tbody>
              <legend id='OKiRl'><style id='OKiRl'><dir id='OKiRl'><q id='OKiRl'></q></dir></style></legend>
              <i id='OKiRl'><tr id='OKiRl'><dt id='OKiRl'><q id='OKiRl'><span id='OKiRl'><b id='OKiRl'><form id='OKiRl'><ins id='OKiRl'></ins><ul id='OKiRl'></ul><sub id='OKiRl'></sub></form><legend id='OKiRl'></legend><bdo id='OKiRl'><pre id='OKiRl'><center id='OKiRl'></center></pre></bdo></b><th id='OKiRl'></th></span></q></dt></tr></i><div id='OKiRl'><tfoot id='OKiRl'></tfoot><dl id='OKiRl'><fieldset id='OKiRl'></fieldset></dl></div>

                • 本文介绍了从 Web 服务器到客户端 bower 的实时通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 php+mysql 开发约会中心 Web 应用程序.我目前尝试做的是在没有第三方推送器和不使用 jQuery SetInterval AJAX 请求的情况下,在从 Web 服务器向客户端/用户 bowers 进行约会时发送通知.我认为 SetInterval &AJAX 是一种糟糕的方法,因为客户端和服务器之间的流量会过多.

                  I am developing an appointments center web application using php+mysql. what I currently trying to do is to send notification when an appointment has been made from web server to client/user bowers without third party pushers and without using jQuery SetInterval AJAX request. I think SetInterval & AJAX is a bad approach because there would be too much traffic between the client and the server.

                  如何在不使用 SetInterval 轮询服务器的情况下实现通知?

                  How can I implement notifications without polling the server with SetInterval?

                  推荐答案

                  您可以使用 NodeJs 做到这一点.NodeJS 是您服务器上的 javascript,可实时将内容推送到连接的客户端.

                  You can do this using NodeJs. NodeJS is javascript on your server that pushes content to connected clients in real time.

                  它非常易于使用和设置.您需要一个专用于实时应用的服务器,我使用 http://nodejitsu.com.

                  Its really easy to use and setup. You need a server dedicated to the real time app, I use http://nodejitsu.com.

                  服务端

                  var app = require('http').createServer(handler)
                  , io = require('socket.io').listen(app)
                  , url = require('url')
                  
                  app.listen(8080);
                  
                  function handler (req, res) {
                  // parse URL
                  var requestURL = url.parse(req.url, true);
                  
                  // if there is a message, send it
                  if(requestURL.query.message)
                      sendMessage(decodeURI(requestURL.query.message));
                  
                  // end the response
                  res.writeHead(200, {'Content-Type': 'text/plain'});
                  res.end("");
                  }
                  
                  function sendMessage(message) {
                  io.sockets.emit('notification', {'message': message});
                  }
                  

                  客户端

                  <script src="socket.io.min.js"></script>
                  <script>
                  var socket = io.connect('http://localhost:8080');
                  socket.on('notification', function (data) {
                      console.log(data.message);
                  });
                  </script>
                  

                  我在下面添加了@intivev 的易于使用的示例,以完成未来读者的答案

                  I added the easy to use example by @intivev below to complete the answer for future readers

                  这篇关于从 Web 服务器到客户端 bower 的实时通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 GCM 向多个 Android 设备发送推送通知 下一篇:如何在访问页面时发送电子邮件通知?

                  相关文章

                  <i id='eY20g'><tr id='eY20g'><dt id='eY20g'><q id='eY20g'><span id='eY20g'><b id='eY20g'><form id='eY20g'><ins id='eY20g'></ins><ul id='eY20g'></ul><sub id='eY20g'></sub></form><legend id='eY20g'></legend><bdo id='eY20g'><pre id='eY20g'><center id='eY20g'></center></pre></bdo></b><th id='eY20g'></th></span></q></dt></tr></i><div id='eY20g'><tfoot id='eY20g'></tfoot><dl id='eY20g'><fieldset id='eY20g'></fieldset></dl></div>

                • <legend id='eY20g'><style id='eY20g'><dir id='eY20g'><q id='eY20g'></q></dir></style></legend>

                    <small id='eY20g'></small><noframes id='eY20g'>

                      • <bdo id='eY20g'></bdo><ul id='eY20g'></ul>
                    1. <tfoot id='eY20g'></tfoot>