本文整理汇总了PHP中Client::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::connect方法的具体用法?PHP Client::connect怎么用?PHP Client::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client::connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_connect_create_a_redis_connection
public function test_connect_create_a_redis_connection()
{
$client = new Client();
$this->assertNull($client->getRedis());
$client->connect();
$this->assertInstanceOf('\\Redis', $client->getRedis());
}
示例2: testClose
public function testClose()
{
$c = new Client();
$c->connect();
$this->assertInstanceOf("Bunny\\Protocol\\MethodChannelCloseOkFrame", $c->channel()->close());
$c->disconnect();
}
示例3: testRunMaxSeconds
public function testRunMaxSeconds()
{
$client = new Client();
$client->connect();
$s = microtime(true);
$client->run(1.0);
$e = microtime(true);
$this->assertLessThan(2.0, $e - $s);
}
示例4: testClose
public function testClose()
{
$c = new Client();
$c->connect();
$promise = $c->channel()->close();
$this->assertInstanceOf("React\\Promise\\PromiseInterface", $promise);
$promise->then(function () use($c) {
$c->stop();
});
$c->run();
}
示例5: propise_diagnostic
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();
}
示例6: testFpmGoesAway
/**
* @medium
*/
public function testFpmGoesAway()
{
// We expect this to fail with a ConnectionException
$this->setExpectedException('\\Crunch\\FastCGI\\ConnectionException');
// Get a MockClient instead of a real one so we can influence the connection's behaviour
$client = new Client('localhost', 42156);
$connection = $client->connect();
$request = $connection->newRequest(array('Foo' => 'Bar', 'GATEWAY_INTERFACE' => 'FastCGI/1.0', 'REQUEST_METHOD' => 'POST', 'SCRIPT_FILENAME' => __DIR__ . '/Resources/scripts/sleep.php', 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', 'CONTENT_LENGTH' => strlen('foo=bar')), 'foo=bar');
$connection->sendRequest($request);
// kill fpm daemon
exec(sprintf('kill %d', $this->pid));
$this->pid = null;
// Try to receive a response, it will either run indefinetly (bad!) or fail as the BE stopped
$connection->receiveResponse($request);
}
示例7: connect
/**
* @return Client
*/
public function connect()
{
$client = new Client();
$client->connect($this->host, $this->port, $this->username, $this->password);
return $client;
}
示例8: __construct
<?php
class Client
{
private $client;
public function __construct()
{
$this->client = new swoole_client(SWOOLE_SOCK_TCP);
}
public function connect()
{
if (!$this->client->connect("127.0.0.1", 9502, 1)) {
echo "Error: {$this->client->errMsg}[{$this->client->errCode}]\n";
}
$msg_eof = "This is a Msg\r\n";
$i = 0;
while ($i < 100) {
$this->client->send($msg_eof);
$i++;
}
}
}
$client = new Client();
$client->connect();
示例9: onClose
swoole_event_add(STDIN, function ($fp) {
$msg = trim(fgets(STDIN));
if ($msg == 'exit') {
$data = json_encode(array('json' => 'Chat', 'ctrl' => 'Chat', 'method' => 'offline', 'name' => $msg));
$this->client->send($data);
exit;
}
$data = json_encode(array('json' => 'Chat', 'ctrl' => 'Chat', 'method' => 'send', 'sendto' => $this->channel, 'msg' => $msg));
$this->client->send($data);
});
}
public function onClose($cli)
{
echo "Client close connection\n";
}
public function onError()
{
var_dump("error");
}
public function send($data)
{
$this->client->send($data);
}
public function isConnected()
{
return $this->client->isConnected();
}
}
$cli = new Client();
$cli->connect();
示例10: onConnect
echo "Get Message From Server: {$data}\n";
}
public function onConnect($cli)
{
fwrite(STDOUT, "Enter Msg:");
swoole_event_add(STDIN, function ($fp) {
global $cli;
fwrite(STDOUT, "Enter Msg:");
$msg = trim(fgets(STDIN));
$cli->send($msg);
});
}
public function onClose($cli)
{
echo "Client close connection\n";
}
public function onError()
{
}
public function send($data)
{
$this->client->send($data);
}
public function isConnected()
{
return $this->client->isConnected();
}
}
$cli = new Client();
$cli->connect($argv[1], $argv[2]);
示例11: testThatWeCanConnectToMaster
public function testThatWeCanConnectToMaster()
{
$master = new Client('192.168.50.40', '6379', null, Client::TYPE_REDIS);
$master->connect();
$this->assertTrue($master->isConnected(), 'We can connect to the master node');
}
示例12: trim
//
// Retour si déjà connecté...
//
if ($_COMPTE) {
$Navig->redirect("compte.php");
}
//////////////////////////////////////////////////
//
// Tester email+password...
//
if (isset($_POST['deja_compte'])) {
$DEMANDE_CONNEXION = true;
$compte_email = trim($_POST['compte_email']);
$compte_passwd = trim($_POST['compte_passwd']);
$Client = new Client();
if ($_COMPTE = $Client->connect($compte_email, $compte_passwd)) {
$Caddie->client($_COMPTE);
// mettre à jour le caddie avec les anciennes et les nouvelles lignes...
$Navig->redirect($Navig->page_demande_connect_compte);
// pour recharger la page qui a demandé la connexion...
} else {
$ERR = trad($Client->err_num);
}
# Ancre...
$ancre = "connexion";
}
//////////////////////////////////////////////////
//
// OUBLI MOT DE PASSE...
//
if (isset($_POST['oubli_passwd_email'])) {
示例13: common_listen
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();
}
}
}
}
示例14: vocalinfo_give_me_all
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();
}
示例15: Client
<?php
namespace Bunny;
require_once __DIR__ . "/../vendor/autoload.php";
$c = new Client();
$ch = $c->connect()->channel();
$ch->queueDeclare("bench_queue");
$ch->exchangeDeclare("bench_exchange");
$ch->queueBind("bench_queue", "bench_exchange");
$t = null;
$count = 0;
$ch->run(function (Message $msg, Channel $ch, Client $c) use(&$t, &$count) {
if ($t === null) {
$t = microtime(true);
}
if ($msg->content === "quit") {
printf("Pid: %s, Count: %s, Time: %.4f\n", getmypid(), $count, microtime(true) - $t);
$c->stop();
} else {
++$count;
}
}, "bench_queue", "", false, true);
$c->disconnect();