update workerman to 3.3.4

This commit is contained in:
walkor
2016-09-20 21:27:41 +08:00
parent a3d823d04a
commit 58dc935eb0
25 changed files with 4159 additions and 2500 deletions
+27 -19
View File
@@ -1,43 +1,51 @@
<?php
/**
* This file is part of workerman.
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor<walkor@workerman.net>
* @copyright walkor<walkor@workerman.net>
* @link http://www.workerman.net/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Workerman\Protocols;
use \Workerman\Connection\ConnectionInterface;
use Workerman\Connection\ConnectionInterface;
/**
* Protocol interface
* @author walkor <walkor@workerman.net>
*/
interface ProtocolInterface
{
/**
* 用于分包,即在接收的buffer中返回当前请求的长度(字节)
* 如果可以在$recv_buffer中得到请求包的长度则返回长度
* 否则返回0,表示需要更多的数据才能得到当前请求包的长度
* 如果返回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.
*
* @param ConnectionInterface $connection
* @param string $recv_buffer
* @param string $recv_buffer
* @return int|false
*/
public static function input($recv_buffer, ConnectionInterface $connection);
/**
* 用于请求解包
* input返回值大于0,并且WorkerMan收到了足够的数据,则自动调用decode
* 然后触发onMessage回调,并将decode解码后的数据传递给onMessage回调的第二个参数
* 也就是说当收到完整的客户端请求时,会自动调用decode解码,无需业务代码中手动调用
* Decode package and emit onMessage($message) callback, $message is the result that decode returned.
*
* @param ConnectionInterface $connection
* @param string $recv_buffer
* @param string $recv_buffer
* @return mixed
*/
public static function decode($recv_buffer, ConnectionInterface $connection);
/**
* 用于请求打包
* 当需要向客户端发送数据即调用$connection->send($data);时
* 会自动把$data用encode打包一次,变成符合协议的数据格式,然后再发送给客户端
* 也就是说发送给客户端的数据会自动encode打包,无需业务代码中手动调用
* Encode package brefore sending to client.
*
* @param ConnectionInterface $connection
* @param mixed $data
* @param mixed $data
* @return string
*/
public static function encode($data, ConnectionInterface $connection);