mirror of
https://github.com/kevachat/npsapp.git
synced 2025-01-15 01:20:31 +00:00
init kevacoin connection, debug server start event
This commit is contained in:
parent
cf4496bc55
commit
c364226dd8
@ -8,6 +8,11 @@
|
||||
"port":9992,
|
||||
"username":"",
|
||||
"password":""
|
||||
},
|
||||
"wallet":
|
||||
{
|
||||
"namespace":"",
|
||||
"account":null
|
||||
}
|
||||
},
|
||||
"nps":
|
||||
@ -45,6 +50,14 @@
|
||||
},
|
||||
"action":
|
||||
{
|
||||
"start":
|
||||
{
|
||||
"debug":
|
||||
{
|
||||
"enabled":true,
|
||||
"template":"[{time}] server started at {host}:{port} balance: {keva}"
|
||||
}
|
||||
},
|
||||
"welcome":
|
||||
{
|
||||
"message":
|
||||
|
@ -18,6 +18,17 @@ $config = json_decode(
|
||||
)
|
||||
); if (!$config) exit;
|
||||
|
||||
// Init KevaCoin
|
||||
$kevacoin = new \Kevachat\Kevacoin\Client(
|
||||
$config->kevacoin->server->protocol,
|
||||
$config->kevacoin->server->host,
|
||||
$config->kevacoin->server->port,
|
||||
$config->kevacoin->server->username,
|
||||
$config->kevacoin->server->password
|
||||
);
|
||||
|
||||
if ((float) $kevacoin->getBalance($config->kevacoin->wallet->account) <= 0) exit;
|
||||
|
||||
// Init session
|
||||
$session = [];
|
||||
|
||||
@ -103,7 +114,7 @@ $server->setWelcome(
|
||||
if ($config->nps->action->welcome->debug->enabled)
|
||||
{
|
||||
// Print debug from template
|
||||
printf(
|
||||
print(
|
||||
str_ireplace(
|
||||
[
|
||||
'{time}',
|
||||
@ -150,7 +161,7 @@ $server->setPending(
|
||||
if ($config->nps->action->pending->debug->enabled)
|
||||
{
|
||||
// Print debug from template
|
||||
printf(
|
||||
print(
|
||||
str_ireplace(
|
||||
[
|
||||
'{time}',
|
||||
@ -239,7 +250,7 @@ $server->setHandler(
|
||||
if ($config->nps->action->handler->debug->enabled)
|
||||
{
|
||||
// Print debug from template
|
||||
printf(
|
||||
print(
|
||||
str_ireplace(
|
||||
[
|
||||
'{time}',
|
||||
@ -273,4 +284,27 @@ $server->setHandler(
|
||||
);
|
||||
|
||||
// Start server
|
||||
$server->start();
|
||||
if ($config->nps->action->start->debug->enabled)
|
||||
{
|
||||
print(
|
||||
str_ireplace(
|
||||
[
|
||||
'{time}',
|
||||
'{host}',
|
||||
'{port}',
|
||||
'{keva}'
|
||||
],
|
||||
[
|
||||
date('c'),
|
||||
$config->nps->server->host,
|
||||
$config->nps->server->port,
|
||||
$kevacoin->getBalance(
|
||||
$config->kevacoin->wallet->account
|
||||
)
|
||||
],
|
||||
$config->nps->action->start->debug->template
|
||||
) . PHP_EOL
|
||||
);
|
||||
}
|
||||
|
||||
$server->start();
|
||||
|
Loading…
x
Reference in New Issue
Block a user