✨ Features: - Migrated ALL files to new S3 structure (Projects, Contacts, Accounts, HelpDesk, Invoice, etc.) - Added Nextcloud folder buttons to ALL modules - Fixed Nextcloud editor integration - WebSocket server for real-time updates - Redis Pub/Sub integration - File path manager for organized storage - Redis caching for performance (Functions.php) 📁 New Structure: Documents/Project/ProjectName_ID/file_docID.ext Documents/Contacts/FirstName_LastName_ID/file_docID.ext Documents/Accounts/AccountName_ID/file_docID.ext 🔧 Technical: - FilePathManager for standardized paths - S3StorageService integration - WebSocket server (Node.js + Docker) - Redis cache for getBasicModuleInfo() - Predis library for Redis connectivity 📝 Scripts: - Migration scripts for all modules - Test pages for WebSocket/SSE/Polling - Documentation (MIGRATION_*.md, REDIS_*.md) 🎯 Result: 15,000+ files migrated successfully!
88 lines
2.1 KiB
PHP
88 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* Упрощенный SSE endpoint для тестирования
|
|
*/
|
|
|
|
// Настройки SSE
|
|
header('Content-Type: text/event-stream');
|
|
header('Cache-Control: no-cache');
|
|
header('Connection: keep-alive');
|
|
header('Access-Control-Allow-Origin: *');
|
|
header('Access-Control-Allow-Headers: Cache-Control');
|
|
|
|
// Отключаем буферизацию
|
|
if (ob_get_level()) {
|
|
ob_end_clean();
|
|
}
|
|
|
|
// Функция для отправки SSE события
|
|
function sendSSEEvent($type, $data) {
|
|
$event = [
|
|
'type' => $type,
|
|
'data' => $data,
|
|
'timestamp' => time()
|
|
];
|
|
|
|
echo "data: " . json_encode($event) . "\n\n";
|
|
flush();
|
|
}
|
|
|
|
// Проверяем подключение
|
|
if (connection_aborted()) {
|
|
exit();
|
|
}
|
|
|
|
// Отправляем начальное событие
|
|
sendSSEEvent('connected', [
|
|
'message' => 'SSE подключение установлено',
|
|
'server_time' => date('Y-m-d H:i:s')
|
|
]);
|
|
|
|
// Основной цикл SSE
|
|
$lastHeartbeat = time();
|
|
$heartbeatInterval = 30; // Heartbeat каждые 30 секунд
|
|
|
|
while (true) {
|
|
// Проверяем подключение
|
|
if (connection_aborted()) {
|
|
break;
|
|
}
|
|
|
|
// Отправляем heartbeat
|
|
if (time() - $lastHeartbeat >= $heartbeatInterval) {
|
|
sendSSEEvent('heartbeat', [
|
|
'timestamp' => time()
|
|
]);
|
|
$lastHeartbeat = time();
|
|
}
|
|
|
|
// Проверяем новые события из файла
|
|
$eventsFile = '/tmp/crm_sse_events.json';
|
|
|
|
if (file_exists($eventsFile)) {
|
|
$events = json_decode(file_get_contents($eventsFile), true);
|
|
|
|
if ($events && is_array($events)) {
|
|
foreach ($events as $event) {
|
|
sendSSEEvent($event['type'], $event['data']);
|
|
}
|
|
|
|
// Очищаем файл после отправки
|
|
unlink($eventsFile);
|
|
}
|
|
}
|
|
|
|
// Пауза между проверками
|
|
sleep(1);
|
|
}
|
|
|
|
// Закрываем соединение
|
|
sendSSEEvent('disconnected', [
|
|
'message' => 'SSE подключение закрыто'
|
|
]);
|
|
?>
|
|
|
|
|
|
|
|
|