Files
Testing/misc_websockets.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

38 lines
1.2 KiB
PHP

<?php
require_once('./include/websocket.php');
class echoServer extends WebSocketServer {
function __construct($addr, $port, $bufferLength="") {
parent::__construct($addr, $port, $bufferLength);
$this->userClass = 'MyUser';
}
//protected $maxBufferSize = 1048576; //1MB... overkill for an echo server, but potentially plausible for other applications.
protected function process ($user, $message) {
$this->send($user,$message);
}
protected function connected ($user) {
// Do nothing: This is just an echo server, there's no need to track the user.
// However, if we did care about the users, we would probably have a cookie to
// parse at this step, would be looking them up in permanent storage, etc.
}
protected function closed ($user) {
// Do nothing: This is where cleanup would go, in case the user had any sort of
// open files or other objects associated with them. This runs after the socket
// has been closed, so there is no need to clean up the socket itself here.
}
}
$echo = new echoServer("99.192.142.83","443");
try {
$echo->run();
}
catch (Exception $e) {
$echo->stdout($e->getMessage());
}
?>