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

Commit

Permalink
ts3admin integration eingefügt
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Paolocci committed Jan 8, 2017
1 parent 858d369 commit 0b8c506
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
"license": "GPL-3.0",
"minimum-stability": "stable",
"require": {
"par0noid/ts3admin": "dev-composer"
"par0noid/ts3admin": "dev-composer",
"laravel/framework": "^5.3"
},
"version": "0.0.1",
"autoload": {
"psr-4": {
"Micky5991\\laravel-ts3admin": "src"
"Micky5991\\laravel_ts3admin\\": "src"
}
},
"repositories": [
Expand Down
16 changes: 16 additions & 0 deletions src/Exceptions/TeamspeakException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace Micky5991\laravel_ts3admin\Exceptions;

use Exception;
use par0noid\ts3admin\ts3admin;

class TeamspeakException extends Exception
{

public function __construct(ts3admin $ts, Exception $previous = NULL)
{
$messages = $ts->getDebugLog();
parent::__construct(end($messages), 0, $previous);
}

}
60 changes: 60 additions & 0 deletions src/Providers/TeamspeakServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace Micky5991\laravel_ts3admin\Providers;

use Illuminate\Support\ServiceProvider;
use par0noid\ts3admin\ts3admin;

class TeamspeakServiceProvider extends ServiceProvider
{
public $defer = true;

/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}

/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->singleton(ts3admin::class, function ($app) {
$ts = new ts3admin(
env('TS_HOST', '127.0.0.1'),
env('TS_QUERY_PORT', 10011),
env('TS_QUERY_SOCKET_TIMEOUT', 2)
);
if ($ts->succeeded($ts->connect())) {
if($ts->succeeded(
$ts->login(
env('TS_QUERY_USER', 'serveradmin'),
env('TS_QUERY_PASS')
)
)) {
if ($ts->succeeded($ts->selectServer(env('TS_SERVER_PORT', 9987)))) {
return $ts;
}
}
}
throw new TeamspeakException($ts);
});
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [ts3admin::class];
}
}

0 comments on commit 0b8c506

Please sign in to comment.