FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

addtimer示例 · bbcsky/framework@6eca8fb · GitHub

Repository navigation

Commit 6eca8fb

Browse files
committed
addtimer示例
1 parent 6e2be30 commit 6eca8fb

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎examples/websocket_server.php‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
class WebSocket extends Swoole\Network\Protocol\WebSocket
77
{
8+
function onStart($serv, $worker_id = 0)
9+
{
10+
$serv->addTimer(1000);
11+
parent::onStart($serv, $worker_id);
12+
}
813
/**
914
* 下线时,通知所有人
1015
*/
@@ -37,6 +42,11 @@ function broadcast($client_id, $msg)
3742
}
3843
}
3944
}
45+
46+
function onTimer($serv, $interval)
47+
{
48+
echo "timer $interval\n";
49+
}
4050
}
4151

4252
//require __DIR__'/phar://swoole.phar';

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL