没有获得更新模型。(not getting updates on model. socket.io with sails.js)
我使用选项
--no-linker --no-front end
创建了一个sails应用程序。 应用程序的前端以angular2
编写。 请求获取和发布,似乎工作正常。当我向路由发送获取请求(订阅)时,我无法获得有关正在创建,更新或销毁的模型的任何更新。
我也创造了一个特别的行动,所以我可以自己做事情,但仍然没有运气。
在路由上执行的更新使用套接字进行。 我不知道这里错在哪里。 在下面找到我的代码
import { Injectable, OnInit, EventEmitter } from '@angular/core' import { Subject } from 'rxjs/Subject'; import { Donor } from './donor.interface'; import * as socketIO from 'socket.io-client' import * as sailsIO from 'sails.io' const url = 'http://localhost:1337' const io = sailsIO(socketIO) io.sails.reconnection = true; io.sails.url = url; io.socket.on('connect', function () { console.log("connected to server") io.socket.get('/donor', function (data, jwres) { console.log("i subscribed", data, jwres) }) io.socket.get('/donor/hello', function (data, jwres) { console.log("i subscribed with hello", data, jwres) }) io.socket.on('donor', function (data) { console.log("new donor was created", data) }); }); io.socket.on('disconnect', function () { console.log('Lost connection to server'); });
DonorController.js
module.exports = { hello: function (req, res) { if (req.isSocket) { Donor.watch(req.socket) console.log("new subscriber found") } else { console.log("not a socket req") } return res.ok(); } };
I have a sails app created using the options
--no-linker --no-front end
. The front end of the application is written inangular2
. Making request get and post, seems to work fine.When i send a get request to the route (to subscribe), i don't get any updates on model being created, updated or destroyed.
I also created a special action, so i could do thing myself, but still with no luck.
The updates performed on the route are made using socket. I don't know where am wrong here. Find my code below
import { Injectable, OnInit, EventEmitter } from '@angular/core' import { Subject } from 'rxjs/Subject'; import { Donor } from './donor.interface'; import * as socketIO from 'socket.io-client' import * as sailsIO from 'sails.io' const url = 'http://localhost:1337' const io = sailsIO(socketIO) io.sails.reconnection = true; io.sails.url = url; io.socket.on('connect', function () { console.log("connected to server") io.socket.get('/donor', function (data, jwres) { console.log("i subscribed", data, jwres) }) io.socket.get('/donor/hello', function (data, jwres) { console.log("i subscribed with hello", data, jwres) }) io.socket.on('donor', function (data) { console.log("new donor was created", data) }); }); io.socket.on('disconnect', function () { console.log('Lost connection to server'); });
DonorController.js
module.exports = { hello: function (req, res) { if (req.isSocket) { Donor.watch(req.socket) console.log("new subscriber found") } else { console.log("not a socket req") } return res.ok(); } };
原文:https://stackoverflow.com/questions/40973346
满意答案
尝试用以下代码替换
didRotateFromInterfaceOrientation
调用:- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration { [UIView animateWithDuration:duration animations:^{ [self redefineLayout]; }]; }
Try replacing your
didRotateFromInterfaceOrientation
call with this:- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration { [UIView animateWithDuration:duration animations:^{ [self redefineLayout]; }]; }
相关问答
更多iPad启动方向(iPad startup orientation)
如何让iPad旋转更流畅?(How to make iPad rotations more fluid?)
如何让我的网站流畅?(how to make my website fluid?)
如何使一个ipad应用程序只有肖像?(How to make an ipad app only portrait?)
Apple iPad HIG?(Apple iPad HIG? [closed])
处理iphone / ipad图像旋转的正确方法是什么?(What is the proper way to handle image rotations for iphone/ipad?)
ipad tabbar旋转(ipad tabbar rotation)
使应用程序在iPhone和iPad上运行(Make an application work on both iPhone and iPad)
在iPad上使用Selenium?(Using Selenium on iPad?)
无法在iPad上禁用旋转功能(Cannot disabled rotation on iPad)
相关文章
更多论 NoSQL 的数据模型
Backbone.js的技巧和模式
SSH中使用了模型驱动
Storm数据流模型的分析及讨论
DHI.MIKE.ZERO.v2007-ISO 1DVD(水利模型系统)
开源项目列表
Sentinel更新计划 Roadmap
rails model的一点疑惑。。。。。
DHI MIKE Zero 2012/DHI MIKE GIS/DHI MIKE URBAN 水利模型系统
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!