如何绑定`ws`消息事件两次,并解除第一个

我使用ws作为节点websocket客户端。

我需要绑定两次客户端stream,然后解除绑定第一个stream。

 var WebSocketServer = require('ws').Server; var wss = new WebSocketServer( { port: 9998 }); wss.on('connection', function(ws) //for every DLL websocket { var wsTL = function(tl) { ws.on('message', function(msg) { cosole.log(msg); } } wsTL(); wsTL(); // ws.on('message',..) is binded again ws.off('message'); // I want to unbind the first event. // but actually, there's no 'off' , so error here } 

可能吗?

谢谢。