public function testCloseChannel() { $client = new Client(); $this->assertInstanceof("Bunny\\Channel", $ch = $client->connect()->channel()); $this->assertInstanceOf("Bunny\\Protocol\\MethodChannelCloseOkFrame", $client->closeChannel($ch)); $client->disconnect(); }
function propise_diagnostic($text, $confidence, $parameters, $myUser) { global $conf; require_once 'Sensor.class.php'; require_once 'Data.class.php'; $sensor = new Sensor(); $data = new Data(); $sensor = $sensor->load(array('location' => $text)); $data = $data->load(array('sensor' => $sensor->id)); $cli = new Client(); $cli->connect(); $cli->talk("Diagnostique pièce : " . $text); $cli->talk("Humidité : " . $data->humidity . ", température : " . $data->temperature . ", Luminosité : " . $data->temperature . "%, mouvement : " . $data->mouvment . "%, bruit : " . $data->sound); $cli->disconnect(); }
namespace Bunny; require_once __DIR__ . "/../vendor/autoload.php"; $c = new Client(); $c->connect(); $ch = $c->channel(); $ch->queueDeclare("bench_queue"); $ch->exchangeDeclare("bench_exchange"); $ch->queueBind("bench_queue", "bench_exchange"); $body = <<<EOT abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza EOT; $time = microtime(true); $max = isset($argv[1]) ? (int) $argv[1] : 1; for ($i = 0; $i < $max; $i++) { $ch->publish($body, [], "bench_exchange"); } echo microtime(true) - $time, "\n"; $ch->publish("quit", [], "bench_exchange"); $c->disconnect();
function vocalinfo_give_me_all($text, $confidence, $parameters) { $cli = new Client(); $cli->connect(); $cli->talk("Je peux parler, evidemment, et t\\'écouter plus précisément qu\\'avant"); $cli->talk("Je peux eprouver et montrer des sentiments"); $cli->talk("Comme la colère"); $cli->emotion("angry"); $cli->talk("Ou la timidité"); $cli->emotion("shy"); $cli->talk("Et tout un tas d\\'autres lubies humaines"); $cli->talk("Je peux aussi exécuter un programme"); $cli->execute("D:\\Programme_installes\\Qt\\Tools\\QtCreator\\bin\\qtcreator.exe"); $cli->talk("ou un son"); $cli->sound("C:/poule.wav"); $cli->talk("ou te montrer des images"); $cli->image("yana.jpg"); $cli->talk("ou executer une commande domotique"); //system('gpio write 1 1'); //$cli->talk("ou executer un humain"); //$cli->talk("non je déconne."); $cli->disconnect(); }
if (!is_null($keyword) && !empty($keyword)) { $result = $helper->parse_board_by_keyword($board, $keyword, $get_count); } else { continue; } } list($new_articles, $update_articles) = $db->process_result($result); echo 'new' . PHP_EOL; print_r($new_articles); echo 'update ' . PHP_EOL; print_r($update_articles); ///// Slack if (!empty($slack_url)) { $slack = new notify_slack($slack_url); $articles = array_merge($new_articles, $update_articles); if (count($articles) > 0) { $slack->notify($articles); } } } //// exit bbs $helper->exitbbs(); echo $client->getScreen(); $client->disconnect(); /// slack push done if (!empty($config['slack']['bot-stat'])) { $slack_uri = $config['slack']['bot-stat']; $slack = new notify_slack($slack_uri); $msg = sprintf("[%s] done", date("D M j G:i:s T Y")); $slack->send($msg); }
<?php include './config.php'; if ($argc < 5) { die("Usage: {$argv[0]} [fromHost] [toHost] [port] [message to send.]\n"); } $fromHost = $argv[1]; $toHost = $argv[2]; $port = $argv[3]; $msg = ""; for ($x = 3; $x < $argc; $x++) { if ($x == $argc - 1) { $msg .= $argv[$x]; } else { $msg .= $argv[$x] . " "; } } try { $myClient = new Client($fromHost, $toHost, $port); echo $myClient->showStatus(); $myClient->startUp(); echo $myClient->showStatus(); $myClient->send($msg); $myClient->disconnect(); echo $myClient->showStatus(); } catch (Exception $e) { die("Fatal error: {$e->getMessage()}\n"); }
public function testClientDisconnect() { self::$client->disconnect(); self::assertTrue(self::$client->is_connected()); }
function common_listen($command, $text, $confidence, $user) { echo "\n" . 'diction de la commande : ' . $command; $response = array(); Plugin::callHook("vocal_command", array(&$response, YANA_URL . '/action.php')); $commands = array(); echo "\n" . 'Test de comparaison avec ' . count($response['commands']) . ' commandes'; foreach ($response['commands'] as $cmd) { if ($command != $cmd['command']) { continue; } if (!isset($cmd['parameters'])) { $cmd['parameters'] = array(); } if (isset($cmd['callback'])) { //Catch des commandes pour les plugins en format client v2 echo "\n" . 'Commande trouvée, execution de la fonction plugin ' . $cmd['callback']; call_user_func($cmd['callback'], $text, $confidence, $cmd['parameters'], $user); } else { //Catch des commandes pour les plugins en format client v1 echo "\n" . 'Commande ancien format trouvée, execution de l\'url ' . $cmd['url'] . '&token=' . $user->getToken(); $result = file_get_contents($cmd['url'] . '&token=' . $user->getToken()); $result = json_decode($result, true); if (is_array($result)) { $client = new Client(); $client->connect(); foreach ($result['responses'] as $resp) { switch ($resp['type']) { case 'talk': $client->talk($resp['sentence']); break; case 'sound': $client->sound($resp['file']); break; case 'command': $client->execute($resp['program']); break; } } $client->disconnect(); } } } }
private function disconnect(Client $client) { // Remove socket from active list $k = array_search($client->socket, $this->sockets); if ($k >= 0) { array_splice($this->sockets, $k, 1); } $client->disconnect(); $this->trigger('client:disconnect', array($this, $client)); }