Umesh Sehta
Umesh Sehta

Reputation: 10683

Object #<Namespace> has no method 'socket'

I am new to node.js i want to emit socket to specific socket id but i am getting Object #<Namespace> has no method 'socket' error. Here is my code:-

 var io = socketio.listen(app)
 io.sockets.on('connection', function (socket) {
    socket.on("user-typing", function (data) {
       io.sockets.socket(socket.id).emit('user-typing-start', "End Typing");//i am getting error here
    })
 });

I am using socket.io v1.0. i have already try this answer but not working:- This

Please help thanks in advance.

Upvotes: 3

Views: 828

Answers (1)

Oleg
Oleg

Reputation: 23287

The code you have provided does not work with Socket.IO 1.0

Instead you may try this solution:

io.to(socket.id).emit('user-typing-start', "End Typing");

or (if you have access to socket object like in your example):

socket.emit('user-typing-start', "End Typing");

Upvotes: 3

Related Questions