1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
$(document).ready(function(){
var path='chemin_de_ton_projet'
,IO
,path=$(location).attr('href').toLowerCase().indexOf('nom_dossier_de_ton_projet')
,host=window.location.host
,socket_path=path.substr(0,path.indexOf(host)+host.length)+':8888/nom_dossier_de_ton_projet';
$.getScript(path+"/node_modules/socket.io-client/socket.io.js",function(){
IO=io.connect(socket_path);
IO.on('connect',function(){
IO.emit('connect',{user:"utilisateur1",message:"l'utilisateur : \"utilisateur1\" vient de se connecter."});//émettre l'événement "connect" à la socket.io
});
});
}); |
Partager