小编Cis*_*idx的帖子

sails.io.js - nodejs - 资源丰富的PubSub没有接收模型事件

我正在尝试订阅nodejs应用程序来模拟帆中的事件.这是我的代码:

var socketIOClient = require('socket.io-client'),
    sailsIOClient = require('sails.io.js');

var io = sailsIOClient(socketIOClient);

io.sails.url = 'http://localhost:1337';

io.socket.on("agent", function(event) {
  console.log(event);
})

io.socket.get("/agent", function(resData, jwres) {})
Run Code Online (Sandbox Code Playgroud)

以下是客户端(nodejs)连接时sails服务器上所有输出的链接:

https://gist.github.com/CiscoKidxx/e5af93ebcc24702ba4f8

我的理解是,当我创建一个新的代理时,它应该触发一个列出更改的console.log(事件).这不会发生.在脚本启动时,我确实得到了"现在连接到风帆".有什么想法吗?

这是我在UserController中创建新代理的呼吁:

Agent.create({
  syncToken: token,
  owner: user.id
}).exec(function (err, newAgent) {
  Agent.publishUpdate(newAgent.id, {syncToken: newAgent.syncToken});
Run Code Online (Sandbox Code Playgroud)

node.js socket.io sails.js

8
推荐指数
1
解决办法
187
查看次数

heroku和风帆应用程序| 崩溃和超时

我有一个非常基本的风帆应用程序并在本地运行.当我部署到Heroku时,我无法从应用程序获得响应,然后最终得到"应用程序错误".我有时收到"没有收到数据".

heroku日志

2015-08-30T22:06:50.949475+00:00 heroku[api]: Release v22 created by me

2015-08-30T22:08:57.324207+00:00 heroku[router]: at=error code=H20 desc="App boo
t timeout" method=GET path="/" host=www.ninjalist.io request_id=8e21f6eb-1a59-4e
31-9c40-00aab002d0f1 fwd="118.61.238.166" dyno= connect= service= status=503 bytes=

2015-08-30T22:08:52.058851+00:00 heroku[web.1]: State changed from starting to down

2015-08-30T22:11:55.735176+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=ninjalist.herokuapp.com request_id=314047d1-97d8-
40ea-8596-4b21978eb581 fwd="108.61.228.166" dyno= connect= service= status=503 b
Run Code Online (Sandbox Code Playgroud)

heroku日志 - 源应用程序

2015-08-30T21:40:42.149449+00:00 app[web.1]: > firstApp@0.0.1 start /app
2015-08-30T21:40:42.149452+00:00 app[web.1]: > sails lift --prod
2015-08-30T21:40:42.149453+00:00 app[web.1]:
2015-08-30T21:40:42.149430+00:00 app[web.1]:
2015-08-30T21:40:42.873435+00:00 app[web.1]: ?[90mStarting app...?[39m
2015-08-30T21:40:42.871270+00:00 app[web.1]:
2015-08-30T21:40:42.873742+00:00 …
Run Code Online (Sandbox Code Playgroud)

heroku sails.js

6
推荐指数
1
解决办法
826
查看次数

以角度访问本地风帆变量

我将两个变量传递给我的视图.如何从角度控制器访问此变量?

风帆控制器:

return res.view('dashboard', {
    me: {
      id: user.id,
      apiKey: user.connection.apiKey
    }
 });
Run Code Online (Sandbox Code Playgroud)

角度控制器:

angular.module('DashboardModule').controller('DashboardController', function($scope, $http) {
  $http.get("/api/" + encodeURIComponent($scope.me.apiKey));
  .success(function(response) {$scope.records = response.records;});
  }
});
Run Code Online (Sandbox Code Playgroud)

HTML:

<h5>Api Key:</h5>
  <p ng-model="me.apiKey"><%= me.apiKey %></p>

  <ul>
    <li ng-repeat="x in records">
      {{ x.guiLoginName }}
    </li>
  </ul>
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我正在尝试对特定的apiKey执行GET,这是一个变量.这个变量可以从EJS访问,但不是有角度的.我究竟做错了什么?公平地说,我从根本上不明白帆与角有什么联系......

angularjs sails.js

3
推荐指数
1
解决办法
653
查看次数

如何在交互式shell中加载python脚本

我正在尝试sudo python get_gps.py -c并期望它加载脚本,然后呈现交互式shell以实时调试脚本,而不是手动输入.

python

2
推荐指数
1
解决办法
266
查看次数

用cheerio刮文本

我想只是凑Jung Ho Kang5,从这个网站,并把它变成一个对象.我想排除(R)和中的所有内容SS.

<td id="lineup-table-top">
  <b class="text-muted pad-left-10">5</b>
  &nbsp;&nbsp;&nbsp;Jung Ho Kang 
  <small class="text-muted">(R)</small> 
  <small class="text-muted">SS</small>
</td>
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

var someObjArr = [];

$('td#lineup-table-top').each(function(i, element){

    //Get the text from cheerio.
    var text = $(this).text();

    //if undefined, create the object inside of our array.
    if(someObjArr[i] == undefined){

        someObjArr[i] = {};
    };

    //Update the salary property of our object with the text value.
    someObjArr[i].name = text;

    $('b.pad-left-10').each(function(i, element){

        //Get the text from cheerio.
        var text = …
Run Code Online (Sandbox Code Playgroud)

javascript node.js cheerio

1
推荐指数
1
解决办法
2318
查看次数

标签 统计

sails.js ×3

node.js ×2

angularjs ×1

cheerio ×1

heroku ×1

javascript ×1

python ×1

socket.io ×1