Consultant, Trainer, Contributor.
RFC6455 released in 2011
Full-Duplex: Client to server and server to client
« Just » a protocol, language agnostic
Only transfer data when useful ≠ polling
Different paradigm, different problems
Memory management, long running process, shared state between clients…
Retrieve sensor data,
Chat and social feeds,
WebSocket server and client written in PHP
Built using ReactPHP ecosystem
Event-driven,non-blocking I/Owith PHP
// 🤓 Low level libraries
Waits for and dispatches events or messages.
$loop = React\EventLoop\Factory::create(); // Register streams to listen on $loop->run();
$stdin = new React\Stream\ReadableResourceStream(STDIN, $loop); $stdout = new React\Stream\WritableResourceStream(STDOUT, $loop);
Two libraries: client and server.
# Server only composer require cboden/ratchet # Client only composer require ratchet/pawl
Client must connect to
Client messages are sent to other connected clients.
Client can define his name to identify himself.
A bit different than the Request / Response model.
👉 Use tools like Supervisor or SystemD.
Do you really need Full-Duplex?
👉 For Server to Client only, check Server-Sent Events!
Sharing code,domain expertise,team knowledge…