Tag: pubnub

Pubnub Node.js防火墙

有任何人都试过在企业防火墙后面的Node.js中的Pubnub ..我可以得到一个简单的node.js应用程序w / pubnub在家工作,但在工作中,我没有收到任何消息。 所以我假设我的防火墙阻止了80端口和443端口的stream量。 这是否意味着当我使用pubnub使用websockets运行node.js? 谢谢! var pubnub = require("pubnub").init({ publish_key : "demo", subscribe_key : "demo", uuid: 'my_custom_uuid' }); pubnub.subscribe({ channel: "my_channel", presence: function(m){console.log(m)}, callback: function(m){console.log(m)} });

build立一个聊天应用程序:如何获得时间

我正在用PubNub创build一个聊天应用程序。 现在的问题是从app / frontend的angular度来看,它应该如何获得时间(服务器时间)。 如果每条消息都发送到服务器,我可以在那里得到服务器的时间。 但是像PubNub这样的第三方服务,我该如何pipe理呢? 由于应用程序发送消息到PubNub而不是我的服务器。 我不想依赖当地时间,因为用户可能会有不准确的时钟。 我想到的最简单的解决scheme是:当应用程序启动时,获得服务器时间。 logging本地时间和服务器时间之间的差异( diff = Date.now() – serverTime )。 发送消息时,时间将是Date.now() – diff 。 这到目前为止是正确的吗? 我想这个解决scheme假设0传输(或等待时间)的时间? 有没有一个更正确的或推荐的方法来实现呢?

Bluemix / Watson自然语言处理无效的API密钥

曾经search过,但在过去一年里找不到类似的问题。 我试图按照这个教程 ,但自从四月份发布以来似乎已经发生了变化。 我已经构build了PubNub模块并注册了一个Bluemix Watson帐户,并设置了一个自然语言理解服务。 当我尝试在PubNub中运行testing包时,我收到错误消息: 23:24:12 js: [“TypeError:无法读取在Sentiment / IBM Watson.js:46:43在process._tickCallback(内部/进程/ next_tick.js:109:7)未定义的属性'types”] Sentiment / IBM Watson.js错误:76:21 at process._tickCallback(internal / process / next_tick.js:109:7) 23:24:13 js: { "body": "{ \"status\": \"ERROR\", \"statusInfo\": \"invalid-api-key\", \"usage\": \"By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html\", […]

Nodejs服务器无法检测到与Pubnub + SocketIO的连接

我的nodejs服务器无法检测到新的浏览器连接(“连接”事件),我不知道为什么。 我缩小了几天工作的一个问题,并怀疑必须添加在浏览器上实现的pubnub套接字连接。 以下是我的server.js var http = require('http') , connect = require('connect') , io = require('socket.io') , fs = require('fs') , uuid = require('node-uuid') , _ = require('lodash'); // pubnub!!! (how to initialize it for use on server) var pubnub = require('pubnub').init({ channel: "my_channel", publish_key: "pub-key", subscribe_key: "sub-c-key", uuid: "Server", origin : 'pubsub.pubnub.com' }); pubnub.subscribe({ channel: […]

如何在pubnub订阅/发布函数中获取channelid?

这我的订阅代码我想要得到的渠道,所以我在代码中使用this.channel ,但我得到了undefined。 有没有什么办法可以得到channelid pubnub.subscribe({ channel: changing dynamically, presence: function (m) { console.log(m) }, message: function (m) { console.log(m); console.log("Channel ==" + this.channel) }, error: function (error) { // Handle error here console.log(JSON.stringify(error)); } }) 结果:Channel ==未定义

推迟在node.js中执行asynchronous消息传递函数

我有一系列经过解码的多段线返回的纬度/经度对。 使用forEach我提取每个纬度/经度对和使用pubnub.publish() ,发送这个数据到一个通道。 pubnub.publish()是一个asynchronous函数,我需要在每一步通过forEach循环来延迟发布消息。 我已经查看了setTimeout立即执行的很多答案,并尝试了下面的不同版本,包括不封装setTimeout在闭包中,但无法延迟发布 – 它只是尽快发送它们。 任何人都可以指出任何明显的错误? decodedPolyline.forEach(function (rawPoints) { var value = { lat: rawPoints[0], lng: rawPoints[1] }; var sendmsg = function () { pubnub.publish({ channel: id, message: value, callback: function (confirmation) { console.log(confirmation); }, error: function (puberror) { console.log('error: ' + puberror); } }); }; (function() { setTimeout(sendmsg, 2000); })(); normalised.push(value); });

正确检索用户名和有用的值(网站标题,版权等)

我有一个基于这个项目的简单的Web应用程序( https://github.com/arthurkao/angular-drywall ),以NodeJS和AngularJS作为前端运行。 我正在设置一个简单的页面,显示地图上所有已连接用户的列表(使用Google地图,地理位置和PubNub)。 以下是我如何做到这一点: angular.module('base').controller('TravelCtrl', function($rootScope, $scope, NgMap, security, $geolocation, PubNub){ $rootScope.extusers = []; //remote users $scope.initTravel = function() { //declare the init function PubNub.init({ subscribe_key: $rootScope.security.keys.psk, publish_key: $rootScope.security.keys.ppk, uuid: $rootScope.security.currentUser.username, ssl: true }); PubNub.ngSubscribe({ channel: "travel", state: { position: {}, } }); console.log("Loaded Travel"); $geolocation.getCurrentPosition({ timeout: 60000 }).then(function(position) { //when location is retreived […]

发布设置Pubnub Nodejs服务器

以下面的示例为例: https : //www.npmjs.org/package/pubnub 我试图build立从我的nodejs服务器连接到pubnub通过: var pubnub = require("pubnub").init({ publish_key: "pub key here", subscribe_key: "sub key here", channel: 'my_channel', user: 'Server' }); pubnub.subscribe({ channel: 'my_channel', callback: function(message) { console.log("Message received: ", message); } }); pubnub.publish({ channel : 'my_channel', callback : function(e) { console.log( "SUCCESS!", e ); }, error : function(e) { console.log( "FAILED! RETRY PUBLISH!", […]

asynchronous发布和订阅消息在pubnub中不起作用

我正在使用下面的代码为pubnub连接。 pubnub = new PubNub({ subscribeKey: "demo", publishKey: "demo", heartbeatInterval: 10, presenceTimeout: 120, keepAlive: true, }) pubnub.addListener({ message: function(message){ console.log(message.channel+' '+message.publisher+' '+message.message.name+' '+time) }, status: function(s) { console.log(s.category+" "+s.operation+" "+s.affectedChannels +" "+s.subscribedChannels +" "+s.affectedChannelGroups+" "+time+" "+s.message) } }); pubnub.history( { //child0, new channel: 'child3', reverse: true, count: 10 }, function (status, response) { // console.log(response); […]

用PubnubreplaceSocket io(WebRTC)

我正在研究使用Pubnub的服务来build立video对等体之间的WebRTC连接。 有了这个,我希望避免使用套接字io这是我目前使用的,虽然我只是找不到任何示范,演示如何做到这一点。 套接字io正在处理从客户端和服务器发出的事件。 据我所知,当前节点的js服务器将不再需要处理任何发射的事件,因为socket io不会被使用,但这是我遇到的问题。 我不知道如何设置客户端互相发送他们需要的信息(谁连接到等) 有没有简单的例子或实现的pubnub被用来代替socket io的一个项目,或者有人可以揭示一些我可能没有看到的东西,谢谢! 编辑:也与任何在Pubnub经验的人,是我正在尝试甚至可能哈哈