Skip to content

Needs Good Documentation #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
christopherperry opened this issue Mar 27, 2015 · 12 comments
Open

Needs Good Documentation #26

christopherperry opened this issue Mar 27, 2015 · 12 comments

Comments

@christopherperry
Copy link

It would be great to see some good documentation in the README, and in the code.

We're trying to use this currently and can't figure out how to get the return values from a method call.

@stefangordon
Copy link
Contributor

Hey Chris! Appreciate you giving it a try. Definitely still in active development. Make sure to check out some of the samples - the TV sample may be the most simple. And feel free to post code/questions here for the primary contributors to take a look at. Also noticed you primarily do Android work - Android support is being worked on at the moment and is not fully supported yet (You can follow the progress in this fork https://github.com/phongcao/cordova-plugin-alljoyn).

@christopherperry
Copy link
Author

We're currently working on a Cordova application, publishing to iPad for now.

How do you implement a method, and call it? Most of the examples deal with signals.

@garethsony
Copy link
Contributor

More specifically, Chris and I have got a question regarding the implementation of application object interface methods. From the examples, it has been demonstrated how to call AllJoyn proxy object methods. But, how do you implement an AllJoyn method from the application object side? So far, I have been able to successfully listen for when an application object’s interface methods have been called. From here, I can change state, etc. on the service side. But, I’m stuck on how to return a value back to the method caller.

For example, let’s say I have the following interface definition:

var applicationObjects = [
    {
        path: /SimpleService”,
        interfaces: [
            [
                “org.alljoyn.bus.samples.simple.CounterInterface”,
                ?getCounter >i”,
                ?setCounter i”,
                ?decrement >i”,
                null
            ],
            null
        ]
    }
];

Now, after connecting, registering the application object, etc. I can successfully listen for when one of these methods is called. E.g.

allJoynBus.addListener([1, 0, 0, 2], , function(args) {
    console.log(“increment called! args =  + args); //This will be printed after the client calls session.callMethod(…).
});

What I would like to do at this point is return a value back to the caller. E.g.

allJoynBus.addListener([1, 0, 0, 2], , function(args) {
    console.log(“increment called! args =  + args);
    return 15; //This is what I would like to be returned to the caller.
});

However, any values I return in the listener’s callback do not seem to make it back to the client. Does this plugin support the ability to return values back to the caller? If so, how?

@vjrantal
Copy link
Contributor

@garethsony Thanks for the detailed problems description!

So far, we have been focusing on use cases where the app using the plugin is more of a client for some service rather than a service in itself. Consequently, the use case you describe hasn't yet been implemented. It is a perfectly valid use case and that is why I created a separate issue to track the implementation progress #27 . Please comment there is you have preferences how you would like it to be implemented!

@christopherperry I think this issue is also a valid one and the documentation could be improved. My thinking has been that the automated tests could be written in a way that they act also as documentation, i.e., add more comments inline to the tests to describe the use case they test tests etc.

@christopherperry
Copy link
Author

@vjrantal Tests are always nice to see. I also like when there are example code snippets in the README, especially when they could cover most simple use cases. Then I don't have to go digging or guess.

@michiyosony
Copy link

@vjrantal We’re also trying to implement the About interface, which necessitates broadcasting a signal with then signature 'qqa(oas)a{sv}'. I’m having trouble trying to correctly format the ‘o’ parameter (object path), and it isn’t clear to me whether the empty case in ALLJoyn_Cordova.m means that this is one of the things that hasn’t been implemented yet or whether it really is marshaled in the same way as a struct. Could you give an example of formatting an object path parameter?

@michiyosony
Copy link

We've also been writing a bit of a "how to" for using the plugin. Would you be open to us creating a pull request adding the information to README.md?

@obsoleted
Copy link
Contributor

@michiyosony Sorry you ran into issues using the plugin. Indeed you did find an error (now tracked in issue #33) where we weren't handling marshaling of object path and signature correctly. The fix should be pretty straightforward so hopefully we can get it in soon.

Also I think the iOS implementation of the plugin actually does try to do About Announcement when advertising a name. However by default the objects/interfaces you register are not advertised.
To accomplish this try adding a flags property to the object being registered with a value of 0x08.

example:

var appObjects = [
      {
        path: "/chatService",
        flags: 0x08, // < -- Added to indicate we want to advertise this object in the announcement
        interfaces: [
          [
            "org.alljoyn.bus.samples.chat",
            "!Chat str>s",
            null
          ],
          null
        ]
      },
      null
    ];

@michiyosony
Copy link

Great; I'll try that out. Thanks!

@stefangordon
Copy link
Contributor

@michiyosony Would be happy to take a PR. I have also gone ahead and enabled the wiki for the project, which may be a good place to contribute more verbose information.

https://github.com/AllJoyn-Cordova/cordova-plugin-alljoyn/wiki

@michiyosony
Copy link

Added what we've come up with to the wiki. Thanks!

@stefangordon
Copy link
Contributor

@michiyosony That is fantastic! Thank you very much. We'd love to hear more about your project - if you are interested in sharing feel free to email me at stefango (at) microsoft.com and we can setup time to chat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants