public function run() { $this->result = $this->ping->run(); if ($this->result > $this->config['max']) { $this->error = 'Maximum ping reached: ' . $this->result . '/' . $this->config['max']; } return parent::run(); }
public function testPingReturnsPong() { $stub = $this->getClientStub(); $stub->expects($this->once())->method('request')->with($this->equalTo('GET'), $this->equalTo('/ping'))->willReturn('pong'); $provider = new Ping($stub); $data = $provider->ping(); $this->assertEquals('pong', $data); }
public static function reload($id, $silent = true) { SystemUtility::log('PING RELOAD START', true); SystemUtility::log('GATHERING DATA'); if (!is_numeric($id)) { if (!$silent) { echo 'Identifier not numeric.'; } $result = false; } else { $ping = \Ping::findFirst($id); if (!$ping) { if (!$silent) { echo 'Ping not found.'; } $result = false; } else { # Reset ping $ping->httpCode = self::HTTP_CODE_IN_PROGRESS; $ping->duration = 0; $ping->error = ''; $ping->save(); $batch = $ping->getBatch(); $url = $batch->getUrl(); $proxy = $ping->getProxy(); $result = self::doPing($ping, $url, $proxy); } } SystemUtility::log('PING RELOAD END', true); return $result; }
public function setUp() { parent::setUp(); $journal = $this->references->getReference('journal'); $this->prePing['contacted'] = $journal->getContacted(); $this->prePing['status'] = $journal->getstatus(); $this->prePing['ojsVersion'] = $journal->getOjsVersion(); $this->prePing['title'] = $journal->getTitle(); $this->prePing['url'] = $journal->getUrl(); $this->ping = $this->getContainer()->get('ping'); $client = new Client(); $this->history = new History(); $client->getEmitter()->attach($this->history); $mock = new Mock([new Response(500, array('Location' => 'http://example.com'))]); $client->getEmitter()->attach($mock); $this->ping->setClient($client); $this->response = $this->ping->ping($journal); }
public function boot($classes) { $res = $this->client->request('POST', self::API_URL . '/servers', ['http_errors' => false, 'json' => ['organization' => $this->organization, 'name' => uniqid() . '-' . getmypid(), 'image' => $this->image, 'tags' => ['gearman']]]); $raw = json_decode($res->getBody(), true); $server = $raw['server']; $res = $this->client->request('POST', self::API_URL . '/servers/' . $server['id'] . '/action', ['http_errors' => false, 'json' => ['action' => 'poweron']]); $raw = json_decode($res->getBody(), true); $host = new Ping($server['public_ip']); do { $latency = $host->ping(); sleep(1); } while (!$latency); $consoleAsync = new ConsoleAsync($this->console); $bootstrap = tempnam(); file_put_contents($bootstrap, json_encode($this->getBootstrap())); $connection = ssh2_connect($server['public_ip'], 22); ssh2_auth_pubkey_file($connection, self::DEFAULT_USER, $this->keys['public'], $this->keys['private']); ssh2_spc_send($connection, $tmp, $this->bootstrap); ssh2_exec($session, $consoleAsync->getCommandString(new HireWorkerCommand(), ['classes' => $classes], ['type' => Worker::LOCAL])); }
/** * Sets the logger object. * * @param Logger $logger the logger object. */ public static function setLogger($logger) { self::$_logger = $logger; }
if (filter_var($r->host, FILTER_VALIDATE_IP)) { $ip = $r->host; } else { $ip = gethostbyname($r->host); // resolve has failed if result matches input if ($ip === $r->host) { $query_update_server_status->execute(array('dns fail', $r->id)); continue; } } // Generate nonce and save to db $nonce = openssl_random_pseudo_bytes(20); $query_insert_server_log->execute(array($r->id, $nonce)); $server_log_id = (int) $db->lastInsertId(); // Send packet $ping = new Ping(); $ping->server_log_id = $server_log_id; $ping->session = $r->session; $ping->nonce = $nonce; //var_dump(unpack('H*', $r->session)); $send_buffer = 'ping' . $ping->serialize(); //$hex_data = unpack('H*', $send_buffer); var_dump($hex_data[1]); socket_sendto($udp_socket, $send_buffer, strlen($send_buffer), MSG_EOR, $ip, $r->port); /* * Update server list */ if ('online' === $r->status) { $servers[] = array((int) $r->id, $r->name, $r->host, (int) $r->port, (int) $r->latency, (int) $r->players, (int) $r->max_players, (int) $r->setting, $r->country_code, (double) $r->latitude, (double) $r->longitude); } } if (!empty($gsl_config['generate_msgpack'])) {
public function testGen() { $ping = new Ping(); $this->assertEquals(new DOMElement('word', 'hi'), $ping->gen()); }
<?php require "Ping.php"; /** * Ping calling */ $email = "*****@*****.**"; $url = "http://www.google.com"; $ping = new Ping($email); $ping->checkUrl($url);
public function ajaxDelete($args) { $manager = new TransactionManager(); $transaction = $manager->get(); $id = $args->id; try { $ping = Ping::findFirst($id); if ($ping) { $ping->setTransaction($transaction); $ping->delete(); $transaction->commit(); $payload['success'] = true; $payload['message'] = 'Ping deleted succesfully.'; } else { $payload['success'] = false; $payload['message'] = 'Ping not found.'; } $payload['payload'] = array('id' => $id); } catch (\Exception $ex) { $transaction->rollback(); $payload['success'] = false; $payload['message'] = 'Error deleting ping.'; $payload['payload'] = array('id' => $id); } return $payload; }
<?php define('ROOT_DIR', realpath(__DIR__ . '/../') . '/'); require_once 'pb_proto_ping.php'; $cmd = new Ping(); $cmd->setType('ping'); $buffer = $cmd->SerializeToString(); $total_length = 4 + strlen($buffer); $buffer = pack('N', $total_length) . $buffer; file_put_contents(ROOT_DIR . 'ping.data', $buffer);