0
我如何识别流星服务器上的特定连接。与您在客户端上使用Session
可以实现的功能类似 - 可以放置与当前连接相关的数据。在Meteor中,无论用户是否登录,我如何识别服务器上的站点用户/连接/用户?
有点像this issue,但在服务器上,而不是客户端。
我可以看到流星账户包使用下面的代码在Meteor.userId
方法:
var currentInvocation = Meteor._CurrentInvocation.get();
if (!currentInvocation)
throw new Error("Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.");
但是当我尝试在我的代码使用Meteor._CurrentInvocation
,它是undefined
,而不是Meteor.EnvironmentVariable
对象,隐含在livedata套餐中。并且,如前缀下划线所示,它是一个私有API,在一般应用程序代码中应该可以避免;)
任何帮助将不胜感激!