无法取消订阅 PubNub [英] Cannot unsubscribe with PubNub
问题描述
我使用 PubNub、Phonegap、Backbone.js 和 Require.js 来构建 twiiter 风格的聊天室.目前我正在使用 chrome 的台式机上进行测试.
Im using PubNub, Phonegap, Backbone.js and Require.js to build twiiter-style chat rooms. Currently I'm testing on a desktop with chrome.
我有一个 Chat.js 视图,在 initialize() 函数中,我订阅了频道:
I have a Chat.js view and in the initialize() function, I subscribe to the channel with:
that.pubnub.subscribe({
channel: chatChannel,
message: that.handleSingleMessage,
});
这很好用,我可以通过 Chrome 检查器看到 ajax 请求被发送.在应用程序的顶部有一个返回"按钮.在这里,我调用 unsubscribe 来取消订阅用户:
This works fine and I can see with Chrome inspector that ajax requests are sent off. At the top of the app there is a "back" button. In here I call unsubscribe to unsubscribe the user:
that.pubnub.unsubscribe({
channel: chatChannel
});
但是,我仍然看到 Chrome 检查器仍然发送到 PubNub 的 ajax 请求,即使用户应该取消订阅并且位于应用程序的不同部分.重复发送2个ajax请求.它们看起来像:
However, I still see with Chrome inspector that ajax requests to PubNub are still being sent off, even though the user should be unsubscribed and is on a different part of the app. 2 ajax requests are repeatedly sent. They look like:
http://ps13.pubnub.com/time/0?uuid=tomsmith&auth=&pnsdk=PubNub%2DTS%2DWeb%2F3%2Y5%2E1
和
http://ps11.pubnub.com/time/0?uuid=4ea9bd1c%2D7652%2D410c%2Da2ba%2D17c5d263085d&auth=&pnsdk=PubNub%2DTS%2DWeb%2F3%2Y5%2E1
知道发生了什么吗?
推荐答案
http://ps13.pubnub.com/time/0?uuid=tomsmith&auth=&pnsdk=PubNub%2DTS%2DWeb%2F3%2Y5%2E1
只是时间"电话.它们用于监控客户端的在线/离线状态,并不代表您仍然订阅.把它们想象成PubNub Pings"
Are just 'time' calls. They are used to monitor the online/offline status of the client, and do not mean that you are still subscribed. Think of them just as "PubNub Pings"
如果您仍然看到包含订阅"的网址,则表示您仍在订阅,例如:
If you still saw a URL with 'subscribe' in it, then that would mean you are still subscribed, for example:
http://ps2.pubnub.com/subscribe/demo/demoapp1%2Cdemoapp1-pnpres/0/13825545216910725?uuid=2f62d1c1-69c8-423c-9492-74e29f46a877&pnsdk=PubNub-JS-Web%2F3.5.47
但从您的示例来看,它只是在您取消订阅后在这里执行心跳逻辑.
but it looks like from your example, its just performing heartbeat logic here, after you've un-subbed.
杰米
这篇关于无法取消订阅 PubNub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!