Skip to content

ddp.on() is not reacting to "result"-messages #5

@ghost

Description

Hi! I'm playing around with ddp.js. I'm trying to build a client that speaks to a meteor server over ddp. But the behaviour i'm seeing is odd. Chances are I'm missing something fundamental.

I have something like this on the client:

var options = {
    endpoint: "ws://localhost:3000/websocket",
    SocketConstructor: WebSocket
};
var ddp = new DDP(options);

ddp.on("connected", function () {
  console.log("Connected");
   var methodId = ddp.method("testMethod");
   ddp.on("result", function (message) {
      console.log(message);
   });
});

testMethod:

Meteor.methods({
    testMethod: function(){
        return "herro";
   }
});

ddp.on("connected") gets triggered as one would expect. However ddp.on("result") does not. When going into the Chrome network console and looking at the DDP-messages being recieved by the client.

{"msg":"result","id":"0","result":"herro"}

But the on() function doesn't react to the event.

Tell me what I'm doing wrong =)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions