diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:26:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:26:02 +0000 |
commit | fcbf3ce37ca8f90a3e36d524a3274ffc063a40e3 (patch) | |
tree | 84c735df2e97350a721273e9dd425729d43cc8a2 /vendor/textalk/websocket/lib/Message | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-pdfexport-fcbf3ce37ca8f90a3e36d524a3274ffc063a40e3.tar.xz icingaweb2-module-pdfexport-fcbf3ce37ca8f90a3e36d524a3274ffc063a40e3.zip |
Adding upstream version 0.10.2+dfsg1.upstream/0.10.2+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/textalk/websocket/lib/Message')
-rw-r--r-- | vendor/textalk/websocket/lib/Message/Binary.php | 8 | ||||
-rw-r--r-- | vendor/textalk/websocket/lib/Message/Close.php | 8 | ||||
-rw-r--r-- | vendor/textalk/websocket/lib/Message/Factory.php | 25 | ||||
-rw-r--r-- | vendor/textalk/websocket/lib/Message/Message.php | 53 | ||||
-rw-r--r-- | vendor/textalk/websocket/lib/Message/Ping.php | 8 | ||||
-rw-r--r-- | vendor/textalk/websocket/lib/Message/Pong.php | 8 | ||||
-rw-r--r-- | vendor/textalk/websocket/lib/Message/Text.php | 8 |
7 files changed, 118 insertions, 0 deletions
diff --git a/vendor/textalk/websocket/lib/Message/Binary.php b/vendor/textalk/websocket/lib/Message/Binary.php new file mode 100644 index 0000000..84d27f5 --- /dev/null +++ b/vendor/textalk/websocket/lib/Message/Binary.php @@ -0,0 +1,8 @@ +<?php + +namespace WebSocket\Message; + +class Binary extends Message +{ + protected $opcode = 'binary'; +} diff --git a/vendor/textalk/websocket/lib/Message/Close.php b/vendor/textalk/websocket/lib/Message/Close.php new file mode 100644 index 0000000..b759fe9 --- /dev/null +++ b/vendor/textalk/websocket/lib/Message/Close.php @@ -0,0 +1,8 @@ +<?php + +namespace WebSocket\Message; + +class Close extends Message +{ + protected $opcode = 'close'; +} diff --git a/vendor/textalk/websocket/lib/Message/Factory.php b/vendor/textalk/websocket/lib/Message/Factory.php new file mode 100644 index 0000000..31df89c --- /dev/null +++ b/vendor/textalk/websocket/lib/Message/Factory.php @@ -0,0 +1,25 @@ +<?php + +namespace WebSocket\Message; + +use WebSocket\BadOpcodeException; + +class Factory +{ + public function create(string $opcode, string $payload = ''): Message + { + switch ($opcode) { + case 'text': + return new Text($payload); + case 'binary': + return new Binary($payload); + case 'ping': + return new Ping($payload); + case 'pong': + return new Pong($payload); + case 'close': + return new Close($payload); + } + throw new BadOpcodeException("Invalid opcode '{$opcode}' provided"); + } +} diff --git a/vendor/textalk/websocket/lib/Message/Message.php b/vendor/textalk/websocket/lib/Message/Message.php new file mode 100644 index 0000000..998caa1 --- /dev/null +++ b/vendor/textalk/websocket/lib/Message/Message.php @@ -0,0 +1,53 @@ +<?php + +namespace WebSocket\Message; + +use DateTime; + +abstract class Message +{ + protected $opcode; + protected $payload; + protected $timestamp; + + public function __construct(string $payload = '') + { + $this->payload = $payload; + $this->timestamp = new DateTime(); + } + + public function getOpcode(): string + { + return $this->opcode; + } + + public function getLength(): int + { + return strlen($this->payload); + } + + public function getTimestamp(): DateTime + { + return $this->timestamp; + } + + public function getContent(): string + { + return $this->payload; + } + + public function setContent(string $payload = ''): void + { + $this->payload = $payload; + } + + public function hasContent(): bool + { + return $this->payload != ''; + } + + public function __toString(): string + { + return get_class($this); + } +} diff --git a/vendor/textalk/websocket/lib/Message/Ping.php b/vendor/textalk/websocket/lib/Message/Ping.php new file mode 100644 index 0000000..908d233 --- /dev/null +++ b/vendor/textalk/websocket/lib/Message/Ping.php @@ -0,0 +1,8 @@ +<?php + +namespace WebSocket\Message; + +class Ping extends Message +{ + protected $opcode = 'ping'; +} diff --git a/vendor/textalk/websocket/lib/Message/Pong.php b/vendor/textalk/websocket/lib/Message/Pong.php new file mode 100644 index 0000000..76a8f9e --- /dev/null +++ b/vendor/textalk/websocket/lib/Message/Pong.php @@ -0,0 +1,8 @@ +<?php + +namespace WebSocket\Message; + +class Pong extends Message +{ + protected $opcode = 'pong'; +} diff --git a/vendor/textalk/websocket/lib/Message/Text.php b/vendor/textalk/websocket/lib/Message/Text.php new file mode 100644 index 0000000..88a22f7 --- /dev/null +++ b/vendor/textalk/websocket/lib/Message/Text.php @@ -0,0 +1,8 @@ +<?php + +namespace WebSocket\Message; + +class Text extends Message +{ + protected $opcode = 'text'; +} |