如何closures一个pubnub连接?

我在一个node.js项目中使用pubnub。 我可以初始化pubnub并发布如下消息:

Node.js的

var PUBNUB = require('pubnub'); var pubnub = PUBNUB.init({ publish_key : 'demo', subscribe_key : 'demo' }); var CHANNEL = 'test1234'; pubnub.subscribe({ channel: CHANNEL, message: function (message) { console.log('Received message:', message); // unsubscribe again pubnub.unsubscribe({channel: CHANNEL}); // PROBLEM: The node.js process does not exit because pubnub is still // active. How to close the pubnub connection so it's completely // gone from memory? }, connect: function () { // send a test message pubnub.publish({channel: CHANNEL, message: 'hello world!'}); } }); 

但是我怎样才能closures这个pubnub实例呢? 这样它就从内存和事件循环中消失了,并且不会让node.js进程继续运行。

我在API文档中找不到任何东西,并且尝试了pubnub.close()pubnub.destroy()pubnub.disconnect()但没有成功。

在较新版本的pubnub中解决了此问题(当前为v3.7.8)。