简体   繁体   English

Rails API + AngularJS + Websocket-Rails gem

[英]Rails API + AngularJS + Websocket-Rails gem

My server is running the websocket-rails gem to handle websockets. 我的服务器正在运行websocket-rails gem来处理websockets。

I'm having trouble using websocket-rails with a phonegap project that uses angular because I need to initialize the websocket-rails client in my Angular front end independent of the rails asset pipeline. 我在使用带有角度的phonegap项目的websocket-rails时遇到了麻烦,因为我需要在我的Angular前端初始化websocket-rails客户端,而不依赖于rails资产管道。

Is it possible to load the websocket-rails client separately into an angular project? 是否可以将websocket-rails客户端单独加载到角度项目中? Or can I use an angular socket directive to manange sockets with websocket-rails? 或者我可以使用角度套接字指令来管理带有websocket-rails的套接字?

I managed to get this working. 我设法让这个工作。

I translated all the coffeescripts into js with the coffescript CLI tool. 我使用coffescript CLI工具将所有coffeescripts翻译成js。 Then I added those files to my project then called the methods in the controller per the websocket-rails docs. 然后我将这些文件添加到我的项目中,然后根据websocket-rails文档调用控制器中的方法。

This guy has done the same translation. 这家伙做了同样的翻译。 A github repo with the translated files. 带翻译文件的github repo。 Hope it can help someone: 希望它可以帮助某人:

https://github.com/karimbutt/websocket-rails-for-js-frameworks https://github.com/karimbutt/websocket-rails-for-js-frameworks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM