PHP Class MyQEE\Server\Clusters\Client

Afficher le fichier Open project: myqee/server

Protected Properties

Свойство 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开始

Méthodes publiques

Méthode 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 投递任务并等待服务器返回

Méthodes protégées

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

Method Details

__construct() public méthode

public __construct ( )

__destruct() public méthode

public __destruct ( )

callbackByString() protected méthode

protected callbackByString ( $str, $rs = false )

callbackFinish() protected méthode

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

close() protected méthode

protected close ( )

connect() protected méthode

连接任务服务器
protected connect ( ) : boolean
Résultat boolean

getClient() public static méthode

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

resource() protected méthode

获取连接客户端
protected resource ( ) : resource | false
Résultat resource | false

sendData() public méthode

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

taskWait() public méthode

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

Property Details

$buffer protected_oe property

未读完的数据
protected string $buffer
Résultat string

$group protected_oe property

所在分组
protected string $group
Résultat string

$instances protected_oe static_oe property

所有 Client 实例化对象
protected static array $instances
Résultat array

$ip protected_oe property

服务器通讯IP
protected string $ip
Résultat string

$key protected_oe property

服务器通讯密钥
protected string $key
Résultat string

$lastTaskId protected_oe property

最后一个任务的投递ID
protected int $lastTaskId
Résultat integer

$port protected_oe property

服务器通讯端口
protected int $port
Résultat integer

$serverId protected_oe property

服务器序号
protected int $serverId
Résultat integer

$socket protected_oe property

protected resource $socket
Résultat resource

$taskCallbackList protected_oe property

protected $taskCallbackList

$workerId protected_oe property

从0开始, task进程也是从0开始
protected int $workerId
Résultat integer