delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

Error using call in client #42

Closed isdzulqor closed 8 years ago

isdzulqor commented 8 years ago

Map<String, Object> signInValues = new HashMap<String, Object>(); signInValues.put("email", email); signInValues.put("password", password); mMeteor.call("/users_booklook/find", signInValues);

why I cant call method with 2 parameter like above in my android .

FranciscoVictor commented 8 years ago

You need to pass the parameters inside Object [] {...}.

mMeteor.call("method_on_the_server", new Object[]{params} );

params can be a single object or a hashmap object like you've used.

ocram commented 8 years ago

Thanks for your question, @isdzulqor, and thanks for helping out, @FranciscoVictor :)

Actually, both is possible. You can pass any number of parameters to the call(...) method. But it's true that the parameters always have to be wrapped in new Object[] { ... }.

Regarding the single parameters, it's not important what type they are of. They may be a string, a number or a Map. Remember that a single Map with several entries is still just one parameter.

So in your example, signInValues is just one parameter, although there are two values in it.

Fixing your example (wrapping in the array) would look like this:

 mMeteor.call("/users_booklook/find", new Object[] { signInValues });

Maybe you really want two parameters, but this would look like the following:

 mMeteor.call("/users_booklook/find", new Object[] { email, password });

You probably don't want that, however.

Anyway, your example probably doesn't work because /users_booklook/find is not a method that you can call. You can't call the find method on Meteor collections directly.

What you could do is define a method like findSomeThing in your Meteor server code that expects two parameters or a map and then returns something.