0
  this.server = net.createServer(this.onAccept);
  this.server.listen(this.port);
}

Server.prototype.onAccept = function () {
  var client = new Client();

  this.addClient(client);
};

Server.prototype.addClient = function (client) {
  this.clients.push(client);
};

I'm getting this error on node.js: this.addClient is not a function on line 27

i don't know why this is occurring.

1 Answers1

0

Most likely your this pointer isn't what you expect, you can bind it explicitly

this.server = net.createServer(this.onAccept.bind(this);
  this.server.listen(this.port);
}
skav
  • 1,400
  • 10
  • 16