Click here to Skip to main content
15,917,795 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear friends,

I have a question about the class parameters. On the code below in the
"emitter.emit('basari',message,id);" line i want to turn back the class's id
parameter but it turns undefined all time. I tried "this.id" the result is the same what can be the problem?

XML
var id;
var EventEmitter = require("events").EventEmitter;
var controller = new EventEmitter();


function TcpClient(socket,id,emitter)
{
    this.id = idNumber;
    this.client=socket;
    this.client.on('data', function(message){
        emitter.emit('basar',message,id);
        console.log("incoming" + message + "\r\n");
    });

}
Posted
Updated 25-Jun-15 9:08am
v4
Comments
CHill60 25-Jun-15 11:12am    
are you sure it is id that undefined and not idNumber?
Sergey Alexandrovich Kryukov 25-Jun-15 15:07pm    
What would it possibly mean, "classes parameters"? Class is not a method with parameter. And not the generic class with generic parameters. Please clarify.
Also, I've fixed HTML formatting of your code. Next time, make sure your code reads correctly.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900