You are here

public static function Utility::serverRun in Rocket.Chat 8

Same name and namespace in other branches
  1. 8.2 src/Utility.php \Drupal\rocket_chat\Utility::serverRun()

ServerRun.

Parameters

string $url: Url to use.

Return value

bool Connection Worked?

1 call to Utility::serverRun()
RocketChatSettingsForm::validateForm in src/Form/RocketChatSettingsForm.php
Form validation handler.

File

src/Utility.php, line 44
Contains \Drupal\rocket_chat\FormManager.

Class

Utility
Check the form values.

Namespace

Drupal\rocket_chat

Code

public static function serverRun($url) {
  $urlSplit = Utility::parseUrl($url);
  try {
    if ($ping = fsockopen($urlSplit['url'], $urlSplit['port'], $errCode, $errStr, 10)) {
      fclose($ping);
      return TRUE;
    }
    else {
      return FALSE;
    }
  } catch (\Exception $exception) {
    error_log("serverRun encountered and exception, check [{$url}] for valid URL");
    return FALSE;
  }
}