PHP RatchetPHP 的 WebSockets 开发包
Ratchet 是一个松耦合的 PHP 库,提供了用于创建实时、双向客户端服务器 WebSockets 应用的支持。
示例代码:
<?php
namespace MyApp;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
class Chat implements MessageComponentInterface {
    public function onOpen(ConnectionInterface $conn) {
    }
    public function onMessage(ConnectionInterface $from, $msg) {
    }
    public function onClose(ConnectionInterface $conn) {
    }
    public function onError(ConnectionInterface $conn, \Exception $e) {
    }
}评论
