PHP Class MyQEE\Server\Clusters\Client

Datei anzeigen Open project: myqee/server

Protected Properties

Property Type Description
$buffer string 未读完的数据
$group string 所在分组
$instances array 所有 Client 实例化对象
$ip string 服务器通讯IP
$key string 服务器通讯密钥
$lastTaskId integer 最后一个任务的投递ID
$port integer 服务器通讯端口
$serverId integer 服务器序号
$socket resource
$taskCallbackList
$workerId integer 从0开始, task进程也是从0开始

Public Methods

Method Description
__construct ( )
__destruct ( )
getClient ( $serverGroup, $serverId, $workerId, $isTask = false ) : Client | false 获取对象
sendData ( string $type, mixed $data, string $workerName, Closure $callback = null ) : boolean 发送数据
taskWait ( mixed $data, float $timeout = 0.5, string $workerName ) : mixed 投递任务并等待服务器返回

Protected Methods

Method Description
callbackByString ( $str, $rs = false )
callbackFinish ( $taskId, $data, $workerName )
close ( )
connect ( ) : boolean 连接任务服务器
resource ( ) : resource | false 获取连接客户端

Method Details

__construct() public method

public __construct ( )

__destruct() public method

public __destruct ( )

callbackByString() protected method

protected callbackByString ( $str, $rs = false )

callbackFinish() protected method

protected callbackFinish ( $taskId, $data, $workerName )

close() protected method

protected close ( )

connect() protected method

连接任务服务器
protected connect ( ) : boolean
return boolean

getClient() public static method

获取对象
public static getClient ( $serverGroup, $serverId, $workerId, $isTask = false ) : Client | false
$serverId
$workerId
return Client | false

resource() protected method

获取连接客户端
protected resource ( ) : resource | false
return resource | false

sendData() public method

发送数据
public sendData ( string $type, mixed $data, string $workerName, Closure $callback = null ) : boolean
$type string 类型: task | msg
$data mixed
$workerName string 当前进程对应的名称
$callback Closure 需要回调的信息, $type = task 时支持
return boolean

taskWait() public method

投递任务并等待服务器返回
public taskWait ( mixed $data, float $timeout = 0.5, string $workerName ) : mixed
$data mixed 数据
$timeout float 超时时间
$workerName string 当前进程对应的名称
return mixed

Property Details

$buffer protected_oe property

未读完的数据
protected string $buffer
return string

$group protected_oe property

所在分组
protected string $group
return string

$instances protected_oe static_oe property

所有 Client 实例化对象
protected static array $instances
return array

$ip protected_oe property

服务器通讯IP
protected string $ip
return string

$key protected_oe property

服务器通讯密钥
protected string $key
return string

$lastTaskId protected_oe property

最后一个任务的投递ID
protected int $lastTaskId
return integer

$port protected_oe property

服务器通讯端口
protected int $port
return integer

$serverId protected_oe property

服务器序号
protected int $serverId
return integer

$socket protected_oe property

protected resource $socket
return resource

$taskCallbackList protected_oe property

protected $taskCallbackList

$workerId protected_oe property

从0开始, task进程也是从0开始
protected int $workerId
return integer