Add data to the connection context to use than in all method calls

When we define a server methods with :

Meteor.methods( {
    myMethod() {
        console.log( this );
} )

It logs base data about the connection ( isSimulation, connection…). The user account package add userId to the context of those methods. And it sticks for every call.

What is the strategy to do the same thing ? Add data in the context of every method call from the client.

what do you want to achieve - i don’t understand?

You’re right, my question is not clear, I edit it.

this inside method holds different information for every calling user (userId, connectionId). That’s the strategy.

I understand that, but where do you set it the data in the connection ? Server side ? Do you have an example ?

When using kadira for instance it adds data.

@fabienhuet take a look at for an elegant solution

1 Like

You can try to monkey-patch meteor methods as decribed here to add properties to context.

Yep, this is what’s done in kadira. I took that approach.