Skip to content

Commit a51ba57

Browse files
committed
testing BridgeClientService
1 parent 4ba47d5 commit a51ba57

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ foo@bar:~/MultigamingPanel$ npm run prod && php artisan migrate
5252

5353
###### Step 6 Configure your webserver to point to the public/ sub-directory
5454

55+
###### Step 6 Open the required ports
56+
```console
57+
foo@bar:~/MultigamingPanel$ ufw allow 443
58+
foo@bar:~/MultigamingPanel$ ufw allow 6001
59+
foo@bar:~/MultigamingPanel$ ufw allow 6660
60+
```
61+
5562
## Emodyz Sponsors
5663

5764
You can sponsor us through various means.

app/Http/Controllers/SettingsController.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
use App\Actions\Emodyz\Settings\EditSettings;
66
use App\Http\Requests\Settings\EditVoiceSettingsRequest;
7+
use App\Services\Bridge\BridgeClientService;
78
use App\Settings\VoiceSettings;
9+
use Exception;
810
use Illuminate\Http\RedirectResponse;
911
use Illuminate\Http\Request;
1012
use Inertia\Response;
@@ -22,13 +24,18 @@ public function __construct()
2224
/**
2325
* Display a listing of the resource.
2426
*
25-
* @param VoiceSettings $voiceSettings
27+
* @param VoiceSettings $voiceSettings
2628
* @return Response|ResponseFactory
29+
* @throws Exception
2730
*/
2831
public function edit(VoiceSettings $voiceSettings)
2932
{
33+
$bridgeClient = new BridgeClientService();
34+
35+
$version = $bridgeClient->getControlPanelVersion();
36+
3037
return inertia('Settings/Edit', [
31-
'currentVersion' => 'v0.21.0',
38+
'currentVersion' => $version,
3239
'voiceSettings' => $voiceSettings->toArray()
3340
]);
3441
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace App\Services\Bridge;
4+
5+
use Bridge\BridgeClient;
6+
use Bridge\GetVersionRequest;
7+
use Exception;
8+
use Illuminate\Contracts\Filesystem\FileNotFoundException;
9+
use Illuminate\Support\Facades\Storage;
10+
11+
class BridgeClientService
12+
{
13+
/**
14+
* @var BridgeClient
15+
*/
16+
private BridgeClient $client;
17+
18+
/**
19+
* BridgeClientService constructor.
20+
* @throws FileNotFoundException
21+
*/
22+
public function __construct()
23+
{
24+
$this->client = new BridgeClient('host.docker.internal:6660', [
25+
'credentials' => \Grpc\ChannelCredentials::createSsl(
26+
Storage::disk('bridge')->get('ca.pem'),
27+
Storage::disk('bridge')->get('cert.key'),
28+
Storage::disk('bridge')->get('cert.crt')
29+
),
30+
]);
31+
}
32+
33+
/**
34+
* @throws Exception
35+
* @return string
36+
*/
37+
public function getControlPanelVersion(): string {
38+
$request = new GetVersionRequest();
39+
list($response, $status) = $this->client->getVersion($request)->wait();
40+
if ($status->code !== \Grpc\STATUS_OK) {
41+
throw new Exception('Error while getting version:' . $status->code . ", " . $status->details . PHP_EOL);
42+
}
43+
return $response->getVersion();
44+
}
45+
}

0 commit comments

Comments
 (0)