Come integrare node.js e socket IO nell'accensione codice.Integrare nodo js e socket IO con codeigniter
<script>
// create a new websocket
var socket = io.connect('http://localhost:8000');
// on message received we print all the data inside the #container div
socket.on('notification', function (data) {
var usersList = "<dl>";
$.each(data.users,function(index,user){
usersList += "<dt>" + user.user_name + "</dt>\n" +
"<dd>" + user.user_description + "\n" +
"<figure> <img class='img-polaroid' width='50px' src='" + user.user_img + "' /></figure>"
"</dd>";
});
usersList += "</dl>";
$('#container').html(usersList);
$('time').html('Last Update:' + data.time);
});
</script>
Come accennato in questa domanda SO here. Il mio file di visualizzazione con codeigniter è in localhost/myproject
ma nodejs ascolta port utilizzando localhost:8000
. Quindi, come posso collegare socket IO
. Mi piace
var socket = io.connect('http://localhost:8000');
//here I need to make socket IO listen to localhost/myproject instead of localhost:8000 .
Com'è possibile?
il percorso viene ignorato dal server socket, a meno che non lo utilizzi per la configurazione in qualche modo, quale socket. io no. – dandavis
Non riesco a capire cosa stai dicendo. Puoi per favore elaborarlo più chiaramente. – user254153
Dai un'occhiata a questo modulo, 'https: // github.com/nodejitsu/node-http-proxy' –