本文整理汇总了PHP中Workerman\Lib\Timer::del方法的典型用法代码示例。如果您正苦于以下问题:PHP Timer::del方法的具体用法?PHP Timer::del怎么用?PHP Timer::del使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workerman\Lib\Timer
的用法示例。
在下文中一共展示了Timer::del方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onMessage
/**
* 设置消息回调
* @return void
*/
public function onMessage($connection, $data)
{
// 删除定时器
Timer::del($connection->timeout_timerid);
$data = json_decode($data, true);
$event = $data['event'];
// 开始验证
switch ($event) {
// 是geteway连接
case 'gateway_connect':
if (empty($data['address'])) {
echo "address not found\n";
return $connection->close();
}
$this->_gatewayConnections[$connection->id] = $data['address'];
$this->broadcastAddresses();
break;
// 是worker连接
// 是worker连接
case 'worker_connect':
$this->_workerConnections[$connection->id] = $connection;
$this->broadcastAddresses($connection);
break;
case 'ping':
break;
default:
echo "unknown event {$event}\n";
$connection->close();
}
}
示例2: clearTimer
public static function clearTimer()
{
if (self::$_reconnectTimer) {
Timer::del(self::$_reconnectTimer);
self::$_reconnectTimer = null;
}
}
示例3: destroy
public function destroy()
{
if ($this->blinkTimeout) {
Timer::del($this->blinkTimeout);
$this->blinkTimeout = 0;
}
if ($this->despawnTimeout) {
Timer::del($this->despawnTimeout);
$this->despawnTimeout = 0;
}
if ($this->isStatic) {
$this->scheduleRespawn(30000);
}
}
示例4: increaseHateFor
public function increaseHateFor($playerId, $points)
{
if ($this->hates($playerId)) {
$obj = Utils::detect($this->hatelist, function ($obj) use($playerId) {
return $obj->id == $playerId;
});
if ($obj) {
$obj->hate += $points;
}
} else {
$this->hatelist[] = (object) array('id' => $playerId, 'hate' => $points);
}
if ($this->returnTimeout) {
// Prevent the mob from returning to its spawning position
// since it has aggroed a new player
Timer::del($this->returnTimeout);
$this->returnTimeout = null;
}
}
示例5: checkWorkerStatus
public static function checkWorkerStatus()
{
foreach (self::$_process as $process_data) {
$process = $process_data[0];
$start_file = $process_data[1];
$timer_id = $process_data[2];
$status = proc_get_status($process);
if (isset($status['running'])) {
// 子进程退出了,重启一个子进程
if (!$status['running']) {
echo "process {$start_file} terminated and try to restart\n";
Timer::del($timer_id);
@proc_close($process);
// 重新打开一个子进程
self::openProcess($start_file);
}
} else {
echo "proc_get_status fail\n";
}
}
}
示例6: onClose
/**
* 当用户断开连接时触发
* @param int $client_id
* @return void
*/
public static function onClose($client_id)
{
\Workerman\Lib\Timer::del(self::$redisConnection->get($client_id));
self::$redisConnection->del($client_id);
// 更新MYSQL数据库
self::$connectHC->query("UPDATE `HC` SET `clientid` = 0, `lastouttime` = CURRENT_TIMESTAMP() WHERE clientid='{$client_id}'");
}
示例7: heartbeat
case 'heartbeat':
// 评测端信息更新
heartbeat($connection, $data);
break;
case 'update_state':
// 评测中更新状态
update_state($connection, $data);
break;
case 'update':
// 评测完更新结果
update($connection, $data);
break;
case 'login':
// 评测端登录
login($connection, $data);
break;
default:
p("Unknown Action ( cid = {$connection->cid}, IP = {$connection->IP} )");
}
};
$worker_tasker->onClose = function ($connection) {
global $cid, $ava_client, $client_sorted;
if ($connection->deadline) {
Timer::del($connection->deadline);
}
if (isset($cid[$connection->cid])) {
unset($cid[$connection->cid]);
$client_sorted = False;
}
p("A client closed the connection. ( cid = {$connection->cid}, IP = {$connection->IP} )");
};
示例8: onClose
public function onClose($reason = '', $description = null)
{
if ('closed' !== $this->readyState) {
Timer::del($this->pingTimeoutTimer);
Timer::del($this->checkIntervalTimer);
$this->checkIntervalTimer = null;
Timer::del($this->upgradeTimeoutTimer);
// clean writeBuffer in next tick, so developers can still
// grab the writeBuffer on 'close' event
$this->writeBuffer = array();
$this->packetsFn = array();
$this->sentCallbackFn = array();
$this->clearTransport();
$this->readyState = 'closed';
$this->emit('close', $this->id, $reason, $description);
$this->server = null;
$this->request = null;
$this->upgradeTransport = null;
$this->removeAllListeners();
if (!empty($this->transport)) {
$this->transport->removeAllListeners();
$this->transport = null;
}
}
}
示例9: dealHandshake
/**
* Websocket handshake.
*
* @param string $buffer
* @param \Workerman\Connection\TcpConnection $connection
* @return int
*/
public static function dealHandshake($buffer, $connection)
{
$pos = strpos($buffer, "\r\n\r\n");
if ($pos) {
// handshake complete
$connection->handshakeStep = 2;
$handshake_response_length = $pos + 4;
// Try to emit onWebSocketConnect callback.
if (isset($connection->onWebSocketConnect)) {
try {
call_user_func($connection->onWebSocketConnect, $connection, substr($buffer, 0, $handshake_response_length));
} catch (\Exception $e) {
Worker::log($e);
exit(250);
} catch (\Error $e) {
Worker::log($e);
exit(250);
}
}
// Headbeat.
if (!empty($connection->websocketPingInterval)) {
$connection->websocketPingTimer = Timer::add($connection->websocketPingInterval, function () use($connection) {
if (false === $connection->send(pack('H*', '8900'), true)) {
Timer::del($connection->websocketPingTimer);
$connection->websocketPingTimer = null;
}
});
}
$connection->consumeRecvBuffer($handshake_response_length);
if (!empty($connection->tmpWebsocketData)) {
$connection->send($connection->tmpWebsocketData, true);
$connection->tmpWebsocketData = '';
}
if (strlen($buffer) > $handshake_response_length) {
return self::input(substr($buffer, $handshake_response_length), $connection);
}
}
return 0;
}
示例10: login
function login($connection, $data)
{
global $db, $cid, $ava_client, $client_sorted;
if (!isset($data['client_id'], $data['client_hash']) || $connection->cid) {
p("Bad Login Action ( IP = {$connection->IP} )");
cut($connection, 'refuse');
return False;
}
$sql = 'SELECT name FROM mo_judge_client WHERE id = ? AND hash = ?';
$mark = $db->prepare($sql);
$db->bind($mark, 'is', $data['client_id'], $data['client_hash']);
$result = $db->execute($mark);
if (!$result) {
p("Bad Client ID or Hash ( IP = {$connection->IP} )");
cut($connection, 'refuse');
return False;
}
Timer::del($connection->deadline);
$connection->deadline = 0;
if (isset($cid[$data['client_id']])) {
cut($cid[$data['client_id']], 'another');
unset($cid[$data['client_id']]);
}
$connection->cid = (string) $data['client_id'];
$connection->name = $result[0]['name'];
$cid[$connection->cid] = $connection;
sendMsg($connection, array('action' => 'admit', 'client_name' => $result[0]['name']));
$client_sorted = False;
p("The client <{$connection->name}> has joined. ( cid = {$connection->cid}, IP = {$connection->IP} )");
return True;
}
示例11: resetTimeout
public function resetTimeout()
{
Timer::del($this->disconnectTimeout);
// 15分钟
$this->disconnectTimeout = Timer::add(15 * 60, array($this, 'timeout'), false);
}
示例12: rmTable
/**
* 废弃桌子
*/
public function rmTable()
{
if ($this->blinkTimeOut) {
Timer::del($this->blinkTimeOut);
}
$this->blinkTimeOut = 0;
foreach ($this->uids as $uid) {
$player = PlayerDao::getPlayer($uid);
if ($player && $player->tableId == $this->tableId) {
PlayerDao::rmPlayer($uid);
}
}
TableDao::rmTable($this->tableId);
}
示例13: reConnect
/**
* Reconnect.
*
* @param int $after
* @return void
*/
public function reConnect($after = 0)
{
$this->_status = self::STATUS_INITIAL;
if ($this->_reconnectTimer) {
Timer::del($this->_reconnectTimer);
}
if ($after > 0) {
$this->_reconnectTimer = Timer::add($after, array($this, 'connect'), null, false);
return;
}
return $this->connect();
}