This repository has been archived by the owner on Feb 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Francesco Paolocci
committed
Jan 8, 2017
1 parent
858d369
commit 0b8c506
Showing
3 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
} | ||
} |