\Workerman\ProtocolsProtocolInterface

Protocol interface

Summary

Methods
Constants
input()
decode()
encode()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

input()

input(string  $recv_buffer, \Workerman\Connection\ConnectionInterface  $connection) : integer|false

Check the integrity of the package.

Please return the length of package. If length is unknow please return 0 that mean wating more data. If the package has something wrong please return false the connection will be closed.

Parameters

string $recv_buffer
\Workerman\Connection\ConnectionInterface $connection

Returns

integer|false

decode()

decode(string  $recv_buffer, \Workerman\Connection\ConnectionInterface  $connection) : mixed

Decode package and emit onMessage($message) callback, $message is the result that decode returned.

Parameters

string $recv_buffer
\Workerman\Connection\ConnectionInterface $connection

Returns

mixed

encode()

encode(mixed  $data, \Workerman\Connection\ConnectionInterface  $connection) : string

Encode package brefore sending to client.

Parameters

mixed $data
\Workerman\Connection\ConnectionInterface $connection

Returns

string