WebSockets!和克里斯·博登



注意:这应视为系列的第2部分。演讲“反应:事件驱动的编程”涵盖了理解WebSockets基础的核心概念。

现在有了异步编程,我们将介绍一个非常有趣且实用的网络编程应用程序:WebSockets! WebSockets是一种允许Web浏览器与服务器之间进行双向实时通信的技术。现在是2013年,让我们已经在网络上推送通知了!

WebSocket是HTML5伞下引入的一项功能,但对开发人员而言,实现中的大部分(也是最难的部分)都是在服务器端完成的。

您将了解什么是WebSocket,它们是如何工作的,它们的缺点和陷阱,以及如何(主要)克服它们。在了解了一些基础知识之后,将向您介绍Ratchet,PHP WebSocket库,以及如何将PHP同步堆栈体系结构与另一种语言/实用程序结合起来,以便在应用程序中使用WebSockets。

最后,我们将回到浏览器并讨论使用情况,浏览器问题/修复程序和消息传递协议。 。

6 comments
  1. for creating private chat (3 users A, B, C and each of them want to chat private), what we need to do 1) create different routes for each user (like you created /chat)
    2) handle it using some other technique like session etc

  2. I have to create a little AJAX chat in my web application and I'm dealing with problem of real-time communication between javascript client and PHP server. I want my js client to be able to catch new messages from the server as quick as possible. My first idea was to create AJAX request for example each 5 sec. to see whether there are new messages. However, I'm not sure what happens if my application use for example 1000 people, it must be huge load to Apache httpd. I also know about technique called 'long-polling' request, but when I tried that locally on my server, I've completely shooted down my Apache (I've read sth about problems with apache and long-polling). The next way I know about is WebSocket. However, is it true that I have to be able to open port on webserver to use it? Because on regular web hosting, I thing it's not possible and I cant change any Apache/PHP settings on my hosting. Do you have any suggestions how to solve it?

Comments are closed.