Skip to content
This repository was archived by the owner on Feb 14, 2021. It is now read-only.

Commit 0b8c506

Browse files
author
Francesco Paolocci
committed
ts3admin integration eingefügt
1 parent 858d369 commit 0b8c506

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
"license": "GPL-3.0",
66
"minimum-stability": "stable",
77
"require": {
8-
"par0noid/ts3admin": "dev-composer"
8+
"par0noid/ts3admin": "dev-composer",
9+
"laravel/framework": "^5.3"
910
},
1011
"version": "0.0.1",
1112
"autoload": {
1213
"psr-4": {
13-
"Micky5991\\laravel-ts3admin": "src"
14+
"Micky5991\\laravel_ts3admin\\": "src"
1415
}
1516
},
1617
"repositories": [

src/Exceptions/TeamspeakException.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
namespace Micky5991\laravel_ts3admin\Exceptions;
3+
4+
use Exception;
5+
use par0noid\ts3admin\ts3admin;
6+
7+
class TeamspeakException extends Exception
8+
{
9+
10+
public function __construct(ts3admin $ts, Exception $previous = NULL)
11+
{
12+
$messages = $ts->getDebugLog();
13+
parent::__construct(end($messages), 0, $previous);
14+
}
15+
16+
}
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace Micky5991\laravel_ts3admin\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
use par0noid\ts3admin\ts3admin;
7+
8+
class TeamspeakServiceProvider extends ServiceProvider
9+
{
10+
public $defer = true;
11+
12+
/**
13+
* Bootstrap the application services.
14+
*
15+
* @return void
16+
*/
17+
public function boot()
18+
{
19+
//
20+
}
21+
22+
/**
23+
* Register the application services.
24+
*
25+
* @return void
26+
*/
27+
public function register()
28+
{
29+
$this->app->singleton(ts3admin::class, function ($app) {
30+
$ts = new ts3admin(
31+
env('TS_HOST', '127.0.0.1'),
32+
env('TS_QUERY_PORT', 10011),
33+
env('TS_QUERY_SOCKET_TIMEOUT', 2)
34+
);
35+
if ($ts->succeeded($ts->connect())) {
36+
if($ts->succeeded(
37+
$ts->login(
38+
env('TS_QUERY_USER', 'serveradmin'),
39+
env('TS_QUERY_PASS')
40+
)
41+
)) {
42+
if ($ts->succeeded($ts->selectServer(env('TS_SERVER_PORT', 9987)))) {
43+
return $ts;
44+
}
45+
}
46+
}
47+
throw new TeamspeakException($ts);
48+
});
49+
}
50+
51+
/**
52+
* Get the services provided by the provider.
53+
*
54+
* @return array
55+
*/
56+
public function provides()
57+
{
58+
return [ts3admin::class];
59+
}
60+
}

0 commit comments

Comments
 (0)