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,在一般應用程序代碼中應該可以避免;)
任何幫助將不勝感激!