app=require('http').createServer(handler);
io=require('socket.io')(app);
app.listen(3000);
function handler(req,res){
var veri=`<!DOCTYPE html>
<html>
<head>
<script src='/socket.io/socket.io.js'></script>
<script>
var socket=io('/');
socket.on('news',function(data){
console.log(data);
socket.emit('my other event',{my:'data'});});
</script>
</head>
<body>
</body>
</html>`;
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(veri);
}
io.on('connection',function(socket){
socket.emit('news',{hello:'world'});
socket.on('my other event',function(data){
console.log(data);
});
});