11. Client/Serveur
1- GET sur http://www.symfony.com
Réponse HTML
http://www.symfony.com - 2
3- GET sur http://www.symfony.com/events
Réponse HTML
http://www.symfony.com/events - 4
Symfony.co
m
Client
5 - GET sur http://www.symfony.com/events
Réponse HTML
http://www.symfony.com/events - 6
12. Web temp réél
1- GET sur http://www.symfony.com
Réponse HTML
http://www.symfony.com - 2
3- GET sur http://www.symfony.com/events
Client
Réponse HTML
http://www.symfony.com/events - 4
Ajout d'un nouvel
evènement - *
Réponse HTML
http://www.symfony.com/events - 5
Ajout d'un nouvel
evènement - *
Réponse HTML
http://www.symfony.com/events - 6
Ajout d'un nouvel
evènement - *
Réponse HTML
http://www.symfony.com/events – 7
Symfony.co
m
13. Qu'est ce que
le Web “temps réel” ?
“..l'utilisateur reçoit des informations au moment où
elles sont publiées sans l'intervention du client...”
14. Utilité du web temps réel
●
Interactivité
●
Rapidité
●
Frontend plus persistant
●
live data
●
Collaboration plus facile
15. Utilisation du web temps réel
●
Chat
●
Interface d'administration
●
Instant charts
●
Notification
●
Statistics
...
●
Games
29. Exemple : serveur node
var io = require('socket.io').listen(8001);
var redis = require('redis').createClient();
redis.psubscribe('socketio_*');
io.sockets.on('connection', function(socket) {
redis.on('pmessage', function(pattern, channel, key) {
socket.emit(channel, key);
});
});
30. Exemple : client socket.io
var socket = io.connect('http://localhost:8001/');
socket.on('socketio_news', function (data) {
var news = $.parseJSON(data);
//do your magic !!
});
});
31. Exemple : interaction depuis SF2
$redis = $this->get('snc_redis.default');
$redis->publish('socketio_news', json_encode([
'title'
=> $entity->getTitle(),
'description' => $entity->getDescription(),
]));
32. Securité
●
●
Sauvegarde de la session PHP dans redis et vérification dans
le serveur NodeJs
Socket.io supporte le SSL
var socket = io.connect('https://localhost', {secure: true});