<?php namespace MyApp; use Ratchet\MessageComponentInterface; use Ratchet\ConnectionInterface; class Chat implements MessageComponentInterface { protected $clients; public function __construct() { $this->clients = new \SplObjectStorage (); } public function onOpen(ConnectionInterface $conn) { // Store the new connection to send messages to later $this->clients->attach ( $conn ); echo "New connecti
![PHPでWebSocketを利用したリアルタイムチャット - フルスタックエンジニアを目指す](https://cdn-ak-scissors.b.st-hatena.com/image/square/8e5412664fefbd95dd68103826144ad0c48f8234/height=288;version=1;width=512/http%3A%2F%2Fchallenge.no1s.biz%2Fwp-content%2Fuploads%2F2017%2F10%2Fphp.png)