How do you attach client data to a server connection?

I present something like this:

# client Meteor.call 'attachData', localStorage.getItem 'clientData' Meteor.connection.onReconnect -> Meteor.call 'attachData', localStorage.getItem 'clientData' setTimeout -> Meteor.call 'logData' , 1000 # server Meteor.methods attachData: (data) -> this.connection.data = data logData: -> console.log this.connection.data 

This seems to work, but I'm not familiar with this.connection . Given this setting, will this.connection.data always be? Should I use Meteor.connection or Meteor.default_connection ?

+5
source share
1 answer

It seems to work. Data is deleted when the connection fails, either by reloading the page, or by interrupting the Internet connection.

https://github.com/lorensr/connection-data

0
source

Source: https://habr.com/ru/post/1235169/


All Articles