Skip to content

Commit 776729c

Browse files
committed
Restructure files
1 parent df96b38 commit 776729c

18 files changed

+46
-53
lines changed

client/test_server.php renamed to cli/client_demo.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
ini_set('display_errors', 1);
33
error_reporting(E_ALL);
44

5-
require_once 'lib/class.websocket_client.php';
5+
require_once __DIR__ . '/../src/Client.php';
66

77
$clients = [];
88
$testClients = 30;
99
$testMessages = 500;
1010
for ($i = 0; $i < $testClients; $i++) {
11-
$clients[$i] = new WebsocketClient;
11+
$clients[$i] = new \Bloatless\WebSocket\Client;
1212
$clients[$i]->connect('127.0.0.1', 8000, '/demo', 'foo.lh');
1313
}
1414
usleep(5000);

cli/server.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
ini_set('display_errors', 1);
4+
error_reporting(E_ALL);
5+
6+
require __DIR__ . '/../src/Connection.php';
7+
require __DIR__ . '/../src/Socket.php';
8+
require __DIR__ . '/../src/Server.php';
9+
10+
require __DIR__ . '/../src/Application/ApplicationInterface.php';
11+
require __DIR__ . '/../src/Application/Application.php';
12+
require __DIR__ . '/../src/Application/DemoApplication.php';
13+
require __DIR__ . '/../src/Application/StatusApplication.php';
14+
15+
$server = new \Bloatless\WebSocket\Server('127.0.0.1', 8000);
16+
17+
// server settings:
18+
$server->setMaxClients(100);
19+
$server->setCheckOrigin(false);
20+
$server->setAllowedOrigin('foo.lh');
21+
$server->setMaxConnectionsPerIp(100);
22+
$server->setMaxRequestsPerMinute(2000);
23+
24+
// Hint: Status application should not be removed as it displays usefull server informations:
25+
$server->registerApplication('status', \Bloatless\WebSocket\Application\StatusApplication::getInstance());
26+
$server->registerApplication('demo', \Bloatless\WebSocket\Application\DemoApplication::getInstance());
27+
28+
$server->run();

client/js/.gitignore

-1
This file was deleted.

client/css/client.css renamed to public/css/client.css

-6
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ h2 {
8787
width: 200px;
8888
margin: 0 0 5px 0;
8989
}
90-
#file {
91-
display: inline-block;
92-
width: 410px;
93-
margin: 0 0 5px 0;
94-
}
95-
9690
.bold {
9791
font-weight: bold;
9892
}

client/css/status.css renamed to public/css/status.css

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ body {
33
padding-top: 65px;
44
text-align: center;
55
font-family: Arial, Helvetica, sans-serif;
6-
text-align: center;
76
font-size: 16px;
87
line-height: 25px;
98
color: #444;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

server/server.php

-28
This file was deleted.

server/lib/WebSocket/Application/Application.php renamed to src/Application/Application.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace WebSocket\Application;
5+
namespace Bloatless\WebSocket\Application;
66

77
/**
88
* WebSocket Server Application

server/lib/WebSocket/Application/ApplicationInterface.php renamed to src/Application/ApplicationInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace WebSocket\Application;
5+
namespace Bloatless\WebSocket\Application;
66

7-
use WebSocket\Connection;
7+
use Bloatless\WebSocket\Connection;
88

99
interface ApplicationInterface
1010
{

server/lib/WebSocket/Application/DemoApplication.php renamed to src/Application/DemoApplication.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace WebSocket\Application;
5+
namespace Bloatless\WebSocket\Application;
66

7-
use WebSocket\Connection;
7+
use Bloatless\WebSocket\Connection;
88

99
/**
1010
* Websocket-Server demo and test application.

server/lib/WebSocket/Application/StatusApplication.php renamed to src/Application/StatusApplication.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace WebSocket\Application;
5+
namespace Bloatless\WebSocket\Application;
66

7-
use WebSocket\Connection;
7+
use Bloatless\WebSocket\Connection;
88

99
/**
1010
* Shiny WSS Status Application

client/lib/class.websocket_client.php renamed to src/Client.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

3-
ini_set('display_errors', 1);
4-
error_reporting(E_ALL);
3+
declare(strict_types=1);
4+
5+
namespace Bloatless\WebSocket;
56

67
/**
78
* Very basic websocket client.
@@ -10,7 +11,7 @@
1011
* @author Simon Samtleben <[email protected]>
1112
* @version 2011-10-18
1213
*/
13-
class WebsocketClient
14+
class Client
1415
{
1516
/**
1617
* @var string $host

server/lib/WebSocket/Connection.php renamed to src/Connection.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace WebSocket;
5+
namespace Bloatless\WebSocket;
66

7-
use WebSocket\Application\ApplicationInterface;
7+
use Bloatless\WebSocket\Application\ApplicationInterface;
88

99
/**
1010
* WebSocket Connection class

server/lib/WebSocket/Server.php renamed to src/Server.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
declare(strict_types=1);
44

5-
namespace WebSocket;
5+
namespace Bloatless\WebSocket;
66

7-
use WebSocket\Application\ApplicationInterface;
7+
use Bloatless\WebSocket\Application\ApplicationInterface;
88

99
/**
1010
* Shiny WSS

server/lib/WebSocket/Socket.php renamed to src/Socket.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace WebSocket;
5+
namespace Bloatless\WebSocket;
66

77
/**
88
* Socket class

0 commit comments

Comments
 (0)