Skip to content

Commit 3612a4a

Browse files
committed
SS14PersistentState
1 parent d1465aa commit 3612a4a

File tree

2 files changed

+35
-5
lines changed

2 files changed

+35
-5
lines changed

run.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,25 @@
1111
$envConfig['HOST_ADDR'] . ':' . $envConfig['HOST_PORT'],
1212
);
1313

14-
$server->init(null, true); // Standalone without an event loop or ReactPHP server
15-
//$server->init(); // Standalone ReactPHP server
14+
//$server->init(null, true); // Standalone without an event loop or ReactPHP server
15+
$server->init(); // Standalone ReactPHP server
1616
$server->setLogger(true); // (Optional) Pass an instance of Psr\Log\LoggerInterface;
1717
$server->setState([
1818
$envConfig['TOKEN'],
1919
$envConfig['STORAGE_TYPE'] ?? 'filesystem',
2020
$envConfig['JSON_PATH'] ?? 'json/verify.json',
2121
]);
22+
$server->setSS14State([
23+
$envConfig['TOKEN'],
24+
$envConfig['STORAGE_TYPE'] ?? 'filesystem',
25+
$envConfig['JSON_PATH'] ?? 'json/ss14verify.json',
26+
]);
2227
$server->setSS14OAuth2Endpoint(
2328
$_ENV['SS14_OAUTH2_CLIENT_ID'] ?? getenv('SS14_OAUTH2_CLIENT_ID'),
2429
$_ENV['SS14_OAUTH2_CLIENT_SECRET'] ?? getenv('SS14_OAUTH2_CLIENT_SECRET')
2530
);
26-
/*$server->setDiscordOAuth2Endpoint(
31+
$server->setDiscordOAuth2Endpoint(
2732
$_ENV['dwa_client_id'] ?? getenv('dwa_client_id'),
2833
$_ENV['dwa_client_secret'] ?? getenv('dwa_client_secret')
29-
);*/
34+
);
3035
$server->start(true); // Start the server and the event loop

src/VerifierServer/Server.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ class Server {
7373
* @var PersistentState Persistent state.
7474
*/
7575
protected PersistentState $state;
76+
/**
77+
* The persistent state.
78+
*
79+
* @var SS14PersistentState Persistent state.
80+
*/
81+
protected SS14PersistentState $ss14state;
7682

7783
/**
7884
* Whether the server has been initialized.
@@ -117,6 +123,11 @@ public function __construct(
117123
$this->addr = $array[0];
118124
$this->port = (int) $array[1];
119125
}
126+
$this->afterConstruct();
127+
}
128+
protected function afterConstruct(): void
129+
{
130+
//$this->endpoints['/usps'] = new USPSEndpoint($_ENV['USPS_USERID'] ?? getenv('USPS_USERID'));
120131
}
121132

122133
/**
@@ -486,6 +497,10 @@ public function getState(): ?PersistentState
486497
{
487498
return $this->state ?? null;
488499
}
500+
public function getSS14State(): ?SS14PersistentState
501+
{
502+
return $this->SS14state ?? null;
503+
}
489504

490505
public function getSessions(): array
491506
{
@@ -536,7 +551,13 @@ public function setState(array|PersistentState $state): void
536551
if (is_array($state)) $state = new PersistentState(...$state);
537552
$this->state = $state;
538553
$this->__setVerifiedEndpoint($state);
539-
//$this->endpoints['/usps'] = new USPSEndpoint($_ENV['USPS_USERID'] ?? getenv('USPS_USERID'));
554+
}
555+
public function setSS14State(array|SS14PersistentState $ss14state): void
556+
{
557+
if (isset($this->ss14state)) return;
558+
if (is_array($ss14state)) $ss14state = new SS14PersistentState(...$ss14state);
559+
$this->ss14state = $ss14state;
560+
$this->__setSS14VerifiedEndpoint($ss14state);
540561
}
541562

542563
/**
@@ -551,6 +572,10 @@ private function __setVerifiedEndpoint(PersistentState &$state): void
551572
$this->endpoints['/verified'] = new VerifiedEndpoint($state);
552573
$this->endpoints['/'] = &$this->endpoints['/verified'];
553574
}
575+
private function __setSS14VerifiedEndpoint(PersistentState &$state): void
576+
{
577+
//$this->endpoints['/ss14verified'] = new VerifiedEndpoint($state);
578+
}
554579

555580
public function setSS14OAuth2Endpoint(
556581
string $client_id,

0 commit comments

Comments
 (0)