Skip to content

Commit 58afa2c

Browse files
committed
Remove request-limit feature and fix some code styles
1 parent 2de64a7 commit 58afa2c

File tree

12 files changed

+133
-223
lines changed

12 files changed

+133
-223
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ $server->setMaxClients(100);
5353
$server->setCheckOrigin(false);
5454
$server->setAllowedOrigin('foo.lh');
5555
$server->setMaxConnectionsPerIp(100);
56-
$server->setMaxRequestsPerMinute(2000);
5756

5857
// Add your applications here:
5958
$server->registerApplication('status', \Bloatless\WebSocket\Application\StatusApplication::getInstance());

cli/server.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

33
require __DIR__ . '/../src/Connection.php';
4-
require __DIR__ . '/../src/Socket.php';
54
require __DIR__ . '/../src/Server.php';
65
require __DIR__ . '/../src/Timer.php';
76
require __DIR__ . '/../src/TimerCollection.php';
@@ -18,7 +17,6 @@
1817
$server->setCheckOrigin(false);
1918
$server->setAllowedOrigin('foo.lh');
2019
$server->setMaxConnectionsPerIp(100);
21-
$server->setMaxRequestsPerMinute(2000);
2220

2321
// Hint: Status application should not be removed as it displays usefull server informations:
2422
$server->registerApplication('status', \Bloatless\WebSocket\Application\StatusApplication::getInstance());

public/js/status.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
const elClientCount = document.getElementById('clientCount');
88
const elMaxClients = document.getElementById('maxClients');
99
const elMaxConnections = document.getElementById('maxConnections');
10-
const elMaxRequetsPerMinute = document.getElementById('maxRequetsPerMinute');
1110

1211
/**
1312
* Adds a new log message.
@@ -62,7 +61,6 @@
6261
elClientCount.textContent = serverinfo.clientCount;
6362
elMaxClients.textContent = serverinfo.maxClients;
6463
elMaxConnections.textContent = serverinfo.maxConnectionsPerIp;
65-
elMaxRequetsPerMinute.textContent = serverinfo.maxRequetsPerMinute;
6664
for (let client in serverinfo.clients) {
6765
if (!serverinfo.clients.hasOwnProperty(client)) {
6866
continue;

public/status.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ <h2>Server Info:</h2>
2222
<p>Connected Clients: <span id="clientCount"></span></p>
2323
<p>Limit Clients: <span id="maxClients"></span></p>
2424
<p>Limit Connections/IP: <span id="maxConnections"></span></p>
25-
<p>Limit Requetes/Min: <span id="maxRequetsPerMinute"></span></p>
2625
</div>
2726

2827
<div class="clearer"></div>

src/Application/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ abstract class Application implements ApplicationInterface
99
/**
1010
* @var array $instances
1111
*/
12-
protected static $instances = [];
12+
protected static array $instances = [];
1313

1414
protected function __construct()
1515
{

src/Application/DemoApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class DemoApplication extends Application
1111
/**
1212
* @var array $clients
1313
*/
14-
private $clients = [];
14+
private array $clients = [];
1515

1616
/**
1717
* Handles new connections to the application.

src/Application/StatusApplication.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@ class StatusApplication extends Application
1313
*
1414
* @var array $clients
1515
*/
16-
private $clients = [];
16+
private array $clients = [];
1717

1818
/**
1919
* Holds IP/Port information of all clients connected to the server.
2020
*
2121
* @var array $serverClients
2222
*/
23-
private $serverClients = [];
23+
private array $serverClients = [];
2424

2525
/**
2626
* Basic server infos (like max. clients e.g.)
2727
*
2828
* @var array $serverInfo
2929
*/
30-
private $serverInfo = [];
30+
private array $serverInfo = [];
3131

3232
/**
3333
* Total number of connected clients.
3434
*
3535
* @var int $serverClientCount
3636
*/
37-
private $serverClientCount = 0;
37+
private int $serverClientCount = 0;
3838

3939
/**
4040
* Handles new connections to the application.

src/Connection.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
class Connection
1010
{
11-
public $waitingForData = false;
11+
public bool $waitingForData = false;
1212

1313
/**
1414
* @var Server $server
1515
*/
16-
private $server;
16+
private Server $server;
1717

1818
/**
1919
* @var resource $socket
@@ -23,33 +23,33 @@ class Connection
2323
/**
2424
* @var bool $handshaked
2525
*/
26-
private $handshaked = false;
26+
private bool $handshaked = false;
2727

2828

2929
/**
3030
* @var ApplicationInterface $application
3131
*/
32-
private $application = null;
32+
private ApplicationInterface $application;
3333

3434
/**
3535
* @var string $ip
3636
*/
37-
private $ip;
37+
private string $ip;
3838

3939
/**
4040
* @var int $port
4141
*/
42-
private $port;
42+
private int $port;
4343

4444
/**
4545
* @var string $connectionId
4646
*/
47-
private $connectionId = '';
47+
private string $connectionId = '';
4848

4949
/**
5050
* @var string $dataBuffer
5151
*/
52-
private $dataBuffer = '';
52+
private string $dataBuffer = '';
5353

5454
/**
5555
* @param Server $server
@@ -109,13 +109,13 @@ private function handshake(string $data): bool
109109
foreach ($lines as $line) {
110110
$line = chop($line);
111111
if (preg_match('/\A(\S+): (.*)\z/', $line, $matches)) {
112-
$headers[ strtolower( $matches[1] )] = $matches[2];
112+
$headers[ strtolower($matches[1])] = $matches[2];
113113
}
114114
}
115115

116116
// check for supported websocket version:
117117
if (!isset($headers['sec-websocket-version']) || $headers['sec-websocket-version'] < 6) {
118-
$this->log('Unsupported websocket version.' );
118+
$this->log('Unsupported websocket version.');
119119
$this->sendHttpResponse(501);
120120
stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
121121
$this->server->removeClientOnError($this);

0 commit comments

Comments
 (0)