spl_autoload_register(function ($className)
{
if (! class_exists($className)) {
$className = str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('_', ' ', $className)));
$className = str_replace('\\', DIRECTORY_SEPARATOR, $className);
return include_once $className . ".php";
}
});
function loadData($data){
$client = yield from \Client\Mysql::new("material");
$resp = yield $client->query("select * from statistic_device limit 1000");
return $resp;
}
function test(){
try{
$client = yield from \Client\WebSocket::new("127.0.0.1","4000");
$client->send("hello");
for($i=0;$i<100;$i++){
$data = yield $client->read();
\Coroutine::task(loadData($data));
$client->send("hello");
}
$client->close();
}catch(Exception $e){
var_dump($e);
}
}
\Coroutine::init();
\Coroutine::task(test());
\Coroutine::wait();
-
Notifications
You must be signed in to change notification settings - Fork 2
jmuyuyang/co-psf
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published