ts3phpframework
Loading...
Searching...
No Matches
Adapter.php
Go to the documentation of this file.
1<?php
2
4
10
15abstract class Adapter
16{
22 protected ?array $options = null;
23
29 protected ?Transport $transport = null;
30
37 public function __construct(array $options)
38 {
39 $this->options = $options;
40
41 if ($this->transport === null) {
42 $this->syn();
43 }
44 }
45
51 abstract public function __destruct();
52
60 abstract protected function syn(): void;
61
67 public function __sleep()
68 {
69 return ["options"];
70 }
71
78 public function __wakeup()
79 {
80 $this->syn();
81 }
82
88 public function getProfiler(): Timer
89 {
90 return Profiler::get(spl_object_hash($this));
91 }
92
98 public function getTransport(): ?Transport
99 {
100 return $this->transport;
101 }
102
111 protected function initTransport(array $options, string $transport = TCP::class): void
112 {
113 $this->transport = new $transport($options);
114 }
115
122 public function getTransportHost(): string
123 {
124 return $this->getTransport()->getConfig("host", "0.0.0.0");
125 }
126
133 public function getTransportPort(): string
134 {
135 return $this->getTransport()->getConfig("port", "0");
136 }
137}
initTransport(array $options, string $transport=TCP::class)
Definition Adapter.php:111
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Adapter\Adapter objects.
Helper class providing profiler timers.
Definition Timer.php:12
Class for connecting to a remote server through TCP.
Definition TCP.php:17
Abstract class for connecting to a TeamSpeak 3 Server through different ways of transport.
Definition Transport.php:17