如何在Laravel网站中使用Meteor服务
我有一个基于Laravel的应用程序。 该应用程序的目的是执行货物交付。 它涉及实时跟踪 另一方面,我正在Angular和Meteor上构建相同的应用程序 同时,我想在Meteor数据库(mongodb)中存储跟踪数据 是否有任何方式可以访问Meteor服务器到我的Laravel应用程序中以显示实时跟踪 更新 我尝试了Paulo Mogollón的解决方案,但我面临着这个错误:如何在Laravel网站中使用Meteor服务,meteor,Meteor,我有一个基于Laravel的应用程序。 该应用程序的目的是执行货物交付。 它涉及实时跟踪 另一方面,我正在Angular和Meteor上构建相同的应用程序 同时,我想在Meteor数据库(mongodb)中存储跟踪数据 是否有任何方式可以访问Meteor服务器到我的Laravel应用程序中以显示实时跟踪 更新 我尝试了Paulo Mogollón的解决方案,但我面临着这个错误: Loading failed for the module with source file:///E:/Dev/la
Loading failed for the module with source file:///E:/Dev/laravelapp/node_modules/isomorphic-ws/index.d.ts
您可以在任何地方使用js和软件包连接到meteor服务器,基本上就是这样做的
npm install simpleddp isomorphic-ws --save
import ws from 'isomorphic-ws';
import simpleDDP from 'simpleDDP'; // ES6
const opts = {
endpoint: "ws://someserver.com/websocket",
SocketConstructor: ws,
reconnectInterval: 5000
};
const server = new simpleDDP(opts);
let userSub = server.subscribe("user_pub");
let otherSub = server.subscribe("other_pub", 'param1', 2); // you can specify arguments for subscription
(async ()=>{
await userSub.ready();
let nextSub = server.subscribe("next_pub"); // subscribing after sub is ready
await nextSub.ready();
//all subs are ready here
})();
您可以在包repo中找到更多示例和信息。希望这能给您带来正确的方向。检查您是否安装了两个模块
npm安装simpledp同构ws--save
顺便问一下,您是否安装了node.js
和npm
?您还应该像webpack一样配置构建管理器。或者,您可以下载这些LIB的简化预编译版本:
import./node\u modules/isomorphic ws/browser.js
现在我得到了TypeError:Error resolving module specifier:simpleddp Core我已经安装了它们,路径也正确。请尝试预编译版本,只需下载它们并作为普通js文件使用。您也可以检查这一点。