0

I trying to extend this module: https://github.com/gildean/node-udp-proxy so it has some kind of method for closing the the proxy when I do not need it anymore. I have tried the following approaches with failure: 1. Trying to extend the code, using inherit. 2. using event emitter to close. 3. Copy the code and extend the module directly by creating the following code in index.js, but I could not manage to call it from the instantiated object.

UdpProxy.prototype.closeClient = function closeClient() {
    var proxy = this;
    //this.close();
    proxy.emit('proxyClose', this.peer);
    this.removeAllListeners();
    delete proxy.connections[senderD];
}

I didnt get any approachs to work yet. I'm a bit of a node.js newbie. I've been reading different articles about inherit but was unable to get the example to work in my context.

Any guidance appreciated.

Thanks

  • Are you sure `close()` as a method on `this`? Looks like it may actually be a method on `client`. Not 100% positive, but it might be worth a shot. – dvlsg Feb 10 '16 at 17:38
  • this.close() gave me an error. Not sure how to implement your suggestion. Could you give me anymore details please? Thx for your reply. How would I access client from the additional code I wrote? – user3015010 Feb 10 '16 at 18:10

1 Answers1

0

I found the solution in the end.

server._server.close();