问题标签 [pubnub]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java-me - pubnub 推送注册表
我正在开发 pubnub j2me sdk 并希望在 j2me 中实现推送通知,因为没有像在 iOS 中那样自动运行应用程序的常规平台,所以套接字/数据报 pushregistry(不想要 sms pushregistry)是唯一的选择这样做任务。
但我不知道如何为 pubnub j2me 实现这个?
iphone - Pubnub iOS:如何更改 Pubnub 委托?
我有2节课。第一个类允许您点击一个按钮来订阅一个频道。第一个类是这样实例化的:
在我的第二堂课中,一切都很好,直到我尝试从 Pubnub 开发者控制台发布消息。当我从开发人员控制台发布消息时,我得到“从 PubNub 频道 {name} 收到 1 条消息的输出。但是我正在使用的可选 Pubnub 委托方法被调用但没有打印出我的 NSLOG。
我将代表设置为我的第一堂课来解决这个问题。但我是 iPhone/objective C 的新手,可以使用一些帮助来将我的 Pubnub 对象的委托设置为第二类。
每当第一堂课时,我都尝试将委托设置为零:viewWillDisappear,然后在第二堂课中再次设置委托:viewWillAppear,但没有运气=(我做错了什么吗?
对不起,如果这令人困惑,我还在学习。:)
javascript - Pubnub Socket.io - 与频道断开连接
使用 Pubnub 的 Socket.io 实现,如何断开通道(或完全断开)?
我这样设置我的连接:
但是当我尝试像这样断开连接时(使用普通 Socket.io 时的方式):
我收到这样的错误消息:
php - 从 JQuery 插件收集使用分析数据
我正在完成一个 JQuery 插件,我需要在插件处于活动状态时收集一些活动的使用数据。这些数据需要远程存储在我的服务器上。
但是,我正在尝试找到执行此操作的最佳方法。我猜这与收集网络分析数据的方式类似。我现在看到两个选项,我概述了以下基本步骤。
A. AJAX - 使用这种方法:
- 我使用 JQuery 在我的 JQuery 插件中设置 Ajax 请求以将数据发布到服务器
- 我设置此服务器以捕获已发布的数据,然后使用 PHP 插入数据库表
B. SOCKETS - 使用这种方法:
- 我注册了 PubNub 之类的服务
- 我在我的 JQuery 插件中使用 PubNub Javascript SDK 将消息“发布”到给定的“频道”
- 我设置了一个专用服务器或云服务器,并使用SSH登录,安装Web服务器+数据库+ PHP,并确保它工作正常
- 我创建了我的 PHP 脚本(使用 PubNub PHP SDK)来“订阅”我的插件将发布消息的 pubnub“频道”,然后设置机制以从消息中捕获数据并插入到数据库表中
- 我设置了 supervisord 来守护我的 php 脚本,然后启动守护进程,因为我需要一个长期存在的 PHP 进程来通过服务器运行 PubNub 订阅功能。
我更喜欢 A,因为它对我来说是最简单的选择,我可以使用任何托管的 MySQL/PHP 服务器以最少的麻烦完成它。但是,我担心当插件在数千个不同的网站或一些非常繁忙的网站中使用时,这种方法的性能如何,在我的远程服务器上每秒可能有 10 到 100 次数据库提交。
将 B 方法与套接字一起使用是否更有意义,因为我需要订阅 PubNub 才能实现这一点,但成本可能要高得多。另外,由于我不需要异步连接,因为我只需要为每个用户发出一个请求,我认为与直接发送到我的服务器的可靠 ol' HTTP 请求相比,套接字可能是矫枉过正的(而不是发送消息通过 PubNub,然后给我)。
真正做到这一点的最好方法是什么?!
提前致谢。
xmlhttprequest - Pubnub 和多个 XHR 请求
我创建了一个带有 pubnub (3.4) 订阅的简单网页,大约每 5 分钟我就会从我的 Chrome 控制台看到一个对 pubnub 的 XHR 请求。这是正确的行为吗?感谢您的任何见解!
iphone - 如何在 iPhone 上为 PubNub 应用程序设置聊天名称?
我正在尝试构建一个使用 PubNub 的应用程序,但我不知道如何设置聊天名称。Github 演示似乎没有处理聊天名称,但不识别聊天来自谁似乎很奇怪。我需要使用某个字典键吗?我试过“chatName”,但没有用。
android - 如何在 Android 应用中使用 PubNub?
我正在尝试开发一个用于社交媒体共享的 Android 应用程序。我知道 PubNub 如何使用云服务器以闪电般的速度和安全性共享数据。我想在我的应用程序中使用它。如果有 API,请告诉我它是如何工作的。
pubnub - pubnub 有 api 吗?
我想从事使用即时消息的个人项目。我想知道是否有像 pubnub 这样向公众开放的 API。
谢谢你
pubnub - Pubnub 回调存在延迟
我使用我的出席回调方法来显示加入或离开我的聊天室的用户,但在用户注销或登录后,此操作似乎非常延迟。是什么原因,我该如何快速响应。
ruby - Ruby callback function to continue execution of another function
I'm using Pubnub to publish live messages from a Server to a client (browser page). When using Pubnub, one must abide by their message size constraints, sometimes resulting in the need to chunk the message, send it in pieces, and reconstruct on the client side. Following Pubnub's advice, one can ensure delivery of each chunk of a message if the Pubnub.publish()
function is not called too quickly (i.e. if the message pieces are simply being pumped through a for loop).
The Pubnub Ruby API specifies 3 required arguments in a Pubnub.publish()
, a channel, a message, and a callback function. The callback function shown below is from Pubnub's Ruby examples:
The message in the callback (not the "hi" message in the publish), contains the status information of the publish()
call with values like "sent" and "message to large", both of which would be accompanied by a unique identifier.
So somewhere under the Pubnub hood, this callback is getting a .call()
- I'm wondering if there is a way for me to get inbetween this process. More detailed, say I have a message that needs to be broken up into three chunks, I would like for chunk 0 to be sent, and upon receipt of a "sent" status in the callback, I would like to then send chunk 1, etc...
I'm not very familiar with lambda functions and their scopes, and this was my first attempt:
This resulted in an utter failure - getting the server completely locked into an infinite while loop because (if I had to guess) pubnub_do_send was never set to true again. Looking at the debug log, I see the first message print ("Message 1 chunk 0 sent") but never the output from the callback function. (Probably because of the infinite while loop it's found itself in)
There must be a clean way to do this, and I'm ok with refactoring code to some extent, chunking up the messages and storing into an array first and then simply looping through the array to send, but I feel like the solution can't be far off, I'm just not too handy with lambda functions and callbacks.
I feel like the solution should look like:
But the problem is my_callback
is called by Pubnub when the Pubnub.publish()
gets some status back about the message rather than me directly calling it! (Is there a way for me to insert message_id, chunk_id, and chunk into the callback while still letting pubnub attach its message to the mix? That sounds way wrong, but maybe with Ruby...)
Thanks in advance for all help.