This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Fonction excutee lors de l'acces a l'url .../charger-messages | |
function send_all_messages() | |
{ | |
date_default_timezone_set("Europe/Paris"); | |
header('Cache-Control: no-cache'); | |
header('Content-type: text/event-stream'); | |
while (true) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row" style="height: 470px;"> | |
<div class="col col-md-4 h-100 overflow-auto overflow-hidden-scroll border-end pe-0"> | |
<div class="list-group" id="list-tab" role="tablist"> | |
<?php foreach ($userDiscussions as $userDiscussion) : | |
/** @var WP_User $second_member */ | |
$second_member = $userDiscussion->member_1 == $user | |
? $userDiscussion->member_2 | |
: $userDiscussion->member_1; | |
require_once('includes/repositories/repository-message.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var event_source, interval; | |
function initEventSource() { | |
event_source = new EventSource(`${host}/charger-messages`) | |
event_source.addEventListener('updated', (event) => { | |
/** @type [[]] */ | |
let all_messages = JSON.parse(event.data).messages_pack | |
let user_id = JSON.parse(event.data).user_id | |
if (all_messages.length > 0) { | |
all_messages.forEach(function (messages) { |