Skip to content

Commit

Permalink
Move sessions to subfolder.
Browse files Browse the repository at this point in the history
Nesting subfolders support.
  • Loading branch information
xtrime-ru committed Jan 14, 2020
1 parent b5672aa commit a831936
Show file tree
Hide file tree
Showing 8 changed files with 298 additions and 30 deletions.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
"require": {
"php": ">=7.4.0",
"ext-json": "*",
"ext-mbstring": "*",
"amphp/http-server": "^2",
"amphp/http-server-router": "^1",
"amphp/websocket-server": "^2",
"vlucas/phpdotenv": "^4",
"danog/madelineproto":"^5"
},
"require-dev": {
"roave/security-advisories": "dev-master"
},
"minimum-stability": "dev",
"prefer-stable": true,
"authors": [
Expand Down
232 changes: 228 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/websocket-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'url' => $options['url'] ?? $options['u'] ?? 'ws://127.0.0.1:9503/events',
];

Amp\Loop::run(function () use($options) {
Amp\Loop::run(static function () use($options) {
echo "Connecting to: {$options['url']}" . PHP_EOL;

try {
Expand Down
10 changes: 8 additions & 2 deletions server.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

use TelegramApiServer\Migrations;

chdir(__DIR__);

require_once __DIR__ . '/bootstrap.php';

if (PHP_SAPI !== 'cli') {
throw new \RuntimeException('Start in CLI');
throw new RuntimeException('Start in CLI');
}

$shortopts = 'a::p::s::';
Expand Down Expand Up @@ -48,6 +50,9 @@
exit;
}

Migrations\Sessions::move(__DIR__);


$sessionFiles = [];
foreach ($options['session'] as $session) {
$session = trim($session);
Expand All @@ -58,8 +63,9 @@
$session = 'session';
}

TelegramApiServer\Client::checkOrCreateSessionFolder($session, __DIR__);
$session = TelegramApiServer\Client::getSessionFile($session);
TelegramApiServer\Client::checkOrCreateSessionFolder($session, __DIR__);

$sessionFiles[$session] = null;
}

Expand Down
Loading

0 comments on commit a831936

Please sign in to comment.