无法弄清楚这段代码中的错误是什么.我试图只在这里发布代码的相关部分.
调节器
myApp.controller('MessageCtrl', function ($scope, notificationService, $rootScope) {
$scope.notificationService = notificationService;
$scope.msgCount = 0;
$scope.notificationService.subscribe({channel : 'my_channel'});
$rootScope.$on('pubnub:msg',function(event,message){
$scope.msgCount = $scope.msgCount + 1;
//$scope.$digest();
});
});
Run Code Online (Sandbox Code Playgroud)
我的通知角度服务
myApp.factory('notificationService',['$rootScope', function($rootScope) {
var pubnub = PUBNUB.init({
publish_key : '..',
subscribe_key : '..'
});
var notificationService = {
subscribe : function(subscription) {
pubnub.subscribe({
channel : subscription.channel,
message : function(m){
$rootScope.$broadcast('pubnub:msg', m);
}
});
}
};
return notificationService;
}]);
Run Code Online (Sandbox Code Playgroud)
和模板:
<div>
Count = {{msgCount}}
</div>
Run Code Online (Sandbox Code Playgroud)
问题:
使用控制台日志和使用karma测试我已经确认当我从Notification Service 执行时调用该$rootScope.$on
方法.并且变量正在增加.但是,我没有看到更新的值在 …
我正在使用pubnub为iOS创建我的第一个应用程序.我能够发送消息并且工作正常.但是我有问题知道哪个用户是发送消息的用户.
我收到此代码的消息
- (void)pubnubClient:(PubNub *)client didReceiveMessage:(PNMessage *)message {
NSLog( @"Mensaje:%@ Canal:%@ %@", message.message, message.channel.name, message.description);
Run Code Online (Sandbox Code Playgroud)
但我不知道如何从这个方法中检索发送消息的UUID或客户端标识符.
有任何想法吗?
提前致谢.对不起,我的英语不好
我最近开始研究pubnub,我正在尝试使用相同的方法制作pub-sub应用程序.我的java和Subscriber的发布者都是javascript.
以下是java中的发布商代码:
Pubnub pubnub = new Pubnub("pub-c-key", "sub-c-key");
pubnub.hereNow("my_channel", cb);
Run Code Online (Sandbox Code Playgroud)
在我的Callable for Here现在我做了一个Sysout响应,我得到以下响应:
{"message":"OK","status":200,"uuids":[],"service":"Presence","occupancy":0}
Run Code Online (Sandbox Code Playgroud)
这是我的JS代码:
<script src=http://cdn.pubnub.com/pubnub.min.js ></script>
<script>(function(){
var pubnub = PUBNUB.init({
publish_key : 'pub-c-key',
subscribe_key : 'sub-c-key'
});
pubnub.subscribe({
channel : "my_channel",
message : function(m){ document.getElementById("my_item").innerHTML = m; },
connect : publish
});
function publish() {
pubnub.publish({
channel : "my_channel",
message : "Connected!"
});
}
})();</script>
Run Code Online (Sandbox Code Playgroud)
但是当我向频道发布内容时,我会将结果显示在执行脚本的网页上. pubnub.publish("my_channel","Offer!" , callback);
为什么现在这不适用于我的情况?任何帮助或领导都可以.我已阅读pubnub文档,但我无法得到它.
使用pubnub我知道可以找到在同一频道上订阅的另一个人的存在.我的问题是,如果我有一个运行的Web应用程序,并且我在我的应用程序中使用pubnub,我是否可以通过使用pubnub api来维护每个用户的状态信息,而无需订阅任何频道.
我14512768065185892
从PubNub 获得了这样的时间令牌.我需要将此时间令牌转换为以下格式dd/mm/yy
.
任何人请提供一种方法将时间戳转换为日期格式.
提前致谢
我试图通过使用esp8266将arduino与pubnub云接口,请建议我将数据从arduino工具包推送到云的最佳解决方案,并从云中获取相同的数据到设备.
我正在尝试将时间戳 2016-02-11 03:31:18 转换为 17 位精度 unix 时间(UTC)的 pubnub 时间戳,例如pubnub给出的参考网址中给出的 13406746780720711 我尝试过以下操作,但没有运气
function parseDateTime(s) {
var b = s.split(/\D/);
return new Date(b[0],b[1]-1,b[2],b[3],b[4],b[5])
}
date = new Date(parseDateTime("2015-02-11 02:10:54") / 10000);
console.log(date.getTime());//142360085
Run Code Online (Sandbox Code Playgroud)
上面的示例给出了142360085
10 个字符的输出,其中 pubnub 要求 17 位时间戳。
这样做的原因是我想获取特定用户的未读消息并通过电子邮件在 EOD 发送电子邮件。
将 mytimestamp 转换为 17 位精度的 unix 时间 (UTC) 后,我会将其传递给pubnub 历史记录函数 并获取未读消息。
我正在调试应用程序中的一些 Posgtres 连接泄漏。几天前,我们突然超过了 100 个连接,而这是不应该的——因为我们只有 8 个独角兽工作线程和一个 sidekiq 进程(25 个线程)。
我今天在查看 htop 时发现我的独角兽工人正在产生大量线程。例如:
我读得正确吗?这不应该发生吧?如果这些是正在生成的线程,知道如何调试它吗?
谢谢!顺便说一句,我的另一个问题 - (Postgres 连接)调试独角兽 postgres 连接泄漏
编辑
我只是在这里遵循了一些提示 - http://varaneckas.com/blog/ruby-tracing-threads-unicorn/ - 当我从工作线程打印堆栈跟踪时,这就是当有很多线程时我得到的结果。
[17176] ---
[17176] /u/apps/eventstream_production/shared/bundle/ruby/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1057:in `pop'
[17176] /u/apps/eventstream_production/shared/bundle/ruby/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1057:in `block in spawn_threadpool'
[17176] ---
[17176] /u/apps/eventstream_production/shared/bundle/ruby/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1057:in `pop'
[17176] /u/apps/eventstream_production/shared/bundle/ruby/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1057:in `block in spawn_threadpool'
[17176] ---
[17176] /u/apps/eventstream_production/shared/bundle/ruby/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1057:in `pop'
[17176] /u/apps/eventstream_production/shared/bundle/ruby/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1057:in `block in spawn_threadpool'
[17176] ---
[17176] /u/apps/eventstream_production/shared/bundle/ruby/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1057:in `pop'
[17176] /u/apps/eventstream_production/shared/bundle/ruby/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1057:in `block in spawn_threadpool'
[17176] ---
[17176] /u/apps/eventstream_production/shared/bundle/ruby/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1057:in `pop'
[17176] /u/apps/eventstream_production/shared/bundle/ruby/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1057:in `block in spawn_threadpool'
[17176] ---
[17176] …
Run Code Online (Sandbox Code Playgroud) 我正在研究本机推送通知。在向任何第三方通知提供商进行购买之前,我正在寻找一些答案
pubnub ×10
javascript ×3
angularjs ×1
arduino ×1
client ×1
esp8266 ×1
eventmachine ×1
head.js ×1
identifier ×1
ios ×1
iot ×1
java ×1
jquery ×1
keen-io ×1
onesignal ×1
pusher ×1
react-native ×1
unicorn ×1
uuid ×1