Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include 'sseFile.php';
- /**
- * Comment creation end point
- */
- function createComment(){
- $submittedComment = $_POST["comment"];
- $comment = new comment();
- $comment->setComment($submittedComment);
- $comment->create();
- sendMsg(); //the SSE fucntion in the other file.
- }
- header('Content-Type: text/event-stream');
- header('Cache-Control: no-cache');
- /**
- * Server side code for SSE.
- * This returns the most recent comment to the front end.
- */
- function sendMsg(){
- $comment = new comment();
- $comment->getLatestComment();
- echo "data: {"msg": "".addcslashes($comment->getComment()."""} nn";
- ob_flush();
- flush();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement