I'm trying to make real time chat with nodeJs.. But i have some problems. The console.log in the part of
io.on('connection', function(socket)
{
console.log("A user connected");
});
does not console.log at all.
When I got stuck i was searching for a guide.. I build it almost the same as in the guide.
Here is my html page:
<!doctype html>
<html>
<head>
<title>
Socket.IO chat
</title>
<link rel="stylesheet" href="./CSS/style.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
<ul id="messages">
</ul>
<form action="">
<input id="m" autocomplete="off" />
<button>
Send
</button>
</form>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
</script>
</body>
</html>
And here my js file:
var app = require("express")(),
http = require("http").Server(app),
io = require("socket.io")(http),
port = 3000;
app.get('/', function(req, res)
{
res.sendFile(__dirname + "./index.html");
});
io.on('connection', function(socket)
{
console.log("A user connected");
});
http.listen(port, function()
{
console.log('Listening on port: ' + port);
});
my file structure:
^because I think it has something to do with the linking between the pages.
I am using this guide: http://socket.io/get-started/chat/
Thanks in advance, I hope to get some answers so i can go on with this :) Cheers