Dan Dascalescu
Dan Dascalescu

Reputation: 151684

Determine what Meteor methods are defined by the server

I'm trying to automate a Meteor app available online (namely, Meteor.com's account management - to add a collaborator to all 170+ organizations I'm a member of).

I've researched reverse engineering Meteor apps but haven't been able to figure out correctly from DDP messages what methods are available on the server.

Meteor methods can be seen among the WebSocket frames by looking for "msg":"method". For example, if you log into https://meteor.com, go to Organizations, and add a username to an organization in your Meteor account, you can see this in the WebSocket frame:

{
    "msg":"method",
    "method":"addOrganizationMember",
    "params":["jspdf", "splendido"],
    "id": "2"
}

(If the output looks uglier than that, vote for the Chrome team to implement this feature request for prettifying WebSocket frame dumps.) That method name, however, failed when running Meteor.call('addOrganizationMember', 'jspdf', 'splendido') in the console, with an error that the method wasn't found (404).

Upvotes: 4

Views: 813

Answers (1)

Matt K
Matt K

Reputation: 4948

So you just want to check if the method exists first & then if it does, make the call?

I think you'd want something like:

if (Meteor.server.method_handlers.addOrganizationMember) { 
  Meteor.call('addOrganizationMember', 'jspdf', 'splendido')
})

For client methods, it'd be Meteor.connection._methodHandlers

Hopefully I understood, set me straight if I didn't.

Upvotes: 1

Related Questions