node.js - Socket Property Of Undefined -
I am currently trying to create a real-time chat room using node, express, and socket.io. When I run the code, I get this error message:
Also, here is my index.js code:
var express = require ("express" ); Var app = express (); Var ports = 3700; App Use (Express. Static (__Drannam + "/ Public")); App.set ("idea", __dirname + "/ tpl"); App.set ("visual engine", "z"); App.Engine ("Z", Required ("Z") .__ Express); App.get ("/", function (req, res) {res.render ("page");}); Io.sockets.on ("connection", function (socket) {socket.emit ("message", {message: "welcome to chat"}); socket.on ("send", function (data) {io Sockets.emit ("Message", Data);});}); Var io = require ("socket.io"). Listen (app.listen (port)); Console.log ("listen on ports" + port); I searched on Google and found no solution related to my code Please help!
Before you begin using the Iio variable before the Iio.sockets var io
var io = require ("socket.io"). Listen (app.listen (port)); Io.sockets.on ("connection", function (socket) {socket.emit ("message", {message: "welcome to chat"}); socket.on ("send", function (data) {io Sockets.emit ("Message", Data);});});
Comments
Post a Comment