Commit dd7219c9 authored by Jamie Carl's avatar Jamie Carl 🤙🏼

Merge branch '26-warlock-client-object-options-update' into 'master'

Resolve "Warlock client object options update"

Closes #26

See merge request !8
parents e8f3e0c8 8355cc0b
This diff is collapsed.
......@@ -28,12 +28,22 @@ class Config {
'win_bg' => false
),
'client' => array(
'port' => null, //Server port override. By default the client will connect to the port in server->port. Useful for reverse proxies or firewalls with port forward, etc.
'server' => null, //Server address override. By default the client will automatically figure out the addresss based on the application config. This can set it explicitly.
'connect' => true, //Connect automatically on startup. If false, connect() must be called manually.
'server' => null, //Server address override. By default the client will automatically figure out the addresss
//based on the application config. This can set it explicitly.
'port' => null, //Server port override. By default the client will connect to the port in server->port.
//Useful for reverse proxies or firewalls with port forward, etc. Allows only the port to
//be overridden but still auto generate the server part.
'ssl' => false, //Use SSL to connect. (wss://)
'websockets' => true, //Use websockets. Alternative is HTTP long-polling.
'url' => null, //Resolved URL override. This allows you to override the entire URL. For the above auto
//URL generator to work, this needs to be NULL.
'check' => 60, //Send a PING if no data is received from the client for this many seconds
'wait' => 5, //Wait this many seconds for a PONG before sending another PING
'pings' => 3, //Disconnect after this many unanswered PING attempts
'ssl' => false //Use SSL to connect. (wss://)
'pingWait' => 5, //Wait this many seconds for a PONG before sending another PING
'pingCount' => 3, //Disconnect after this many unanswered PING attempts
'reconnect' => true, //When using WebSockets, automatically reconnect if connection is lost.
'reconnectDelay' => 0,
'reconnectRetries' => 0
),
'timeouts' => array(
'startup' => 1000, //Timeout for Warlock\Control to wait for the server to start
......
......@@ -1333,7 +1333,7 @@ class Server extends WebSockets {
$client->handshake = TRUE;
$result = $this->processCommand($socket, $client, $type, $payload);
$result = $this->processCommand($socket, $client, $type, $payload, time());
return !$result; // If $result is TRUE then we disconnect. If it is FALSE we do NOT disconnect.
......
......@@ -44,29 +44,29 @@ class Warlock extends \Hazaar\View\Helper {
$config = new \Hazaar\Application\Config('warlock', APPLICATION_ENV, \Hazaar\Warlock\Config::$default_config);
$config->client['sid'] = $config->sys->id;
if($config->client['port'] === null)
$config->client['port'] = $config->server['port'];
if($config->client['server'] !== null)
$host = $config->client['server'] . ':' . $config->client['port'] . '/' . APPLICATION_NAME;
elseif(trim($config->server['listen']) == '0.0.0.0')
$host = $_SERVER['SERVER_NAME'] . ':' . $config->client['port'] . '/' . APPLICATION_NAME;
else
$host = $config->server['listen'] . ':' . $config->client['port'] . '/' . APPLICATION_NAME;
$wsEnabled = strbool($config->websockets->enabled === true);
if($config->client['server'] === null){
$wsAutoReconnect = strbool($config->websockets->autoReconnect === true);
if(trim($config->server['listen']) == '0.0.0.0')
$config->client['server'] = $_SERVER['SERVER_NAME'];
else
$config->client['server'] = $config->server['listen'];
$wsSSL = strbool($config->websockets->ssl === true || $config->client->ssl === true);
}
$view->script("{$this->js_varname} = new HazaarWarlock('{$config->sys->id}', '$host', $wsEnabled, $wsAutoReconnect, $wsSSL);");
if($config->client['applicationName'] === null)
$config->client['applicationName'] = APPLICATION_NAME;
if($config->server->encoded === true)
$view->script("{$this->js_varname}.enableEncoding();");
$config->client['encoded'] = $config->server->encoded;
if(($user = ake($_SERVER, 'REMOTE_USER')))
$view->script("{$this->js_varname}.setUser('$user');");
$config->client['username'] = $user;
$view->script("{$this->js_varname} = new HazaarWarlock(" . $config->client->toJSON() . ');');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment