Menu
Reference
- Manticore\Ds
- Async
- Http
- Http\WebSocket
- Interfaces
- Handler
- Classes
- Connection
- ConnectionClosedException
- HandshakeException
- Hub
- Message
- Options
- Functions
- connect()
- handler()
- run()
- upgrade()
- Buffer
- Process
- Io\Poll
- Manticore\Sapi
- Ffi
run()
function
function run(Connection $c, Handler $h): void
Drive a connection through a Handler until it ends.
Calls onOpen, then onMessage for each message, then onClose exactly once, whichever way the loop ends. An exception from onOpen or onMessage goes to onError and the connection is closed with 1011; an exception from onError is discarded. A cancelled task is not reported to onError. This is the client-side counterpart of handler(); it reads, so it also keeps the connection alive.
Parameters
$cConnection- the connection to drive
$hHandler- the callbacks
See also: handler