CEP-Resources
CEP-Resources copied to clipboard
Add a callback function parameter to requestOpenExtension function
The current requestOpenExtension() function is non-blocking call but doesn't provide a callback parameter. There is no reliable way to run certain actions right after the extension get started. A callback parameter needs to be added to the function.
You can use another way to achieve this.
- In extension 1, you call requestOpenExtension() to open extension 2.
- Extension 2 sends a CEP event to extension 1.
- When extension 1 receives the event, you know extension 2 has been launched, and the event callback is the call back you need.
That's exact the workaround we are currently using. But the workflow is buggy since each extension has its own life-cycle and it is controlled by the host application. It is very tricky for extension 2 to fire the event. When should extension 2 fire the event. Extension 2 can be started up by the host application (no need to fire an event) or started up by extension 1 via requestOpenExtension() function (need fire the event). We eventually got it working after fixing a bunch of problems.
A callback parameter on requestOpenExtension() function can solve all those problems and make the workflow clean and bug-free.
@sujaisivanandan could you update the community the reason of closing the issue, fixed, not in the plan, as design, etc.?
Yes, please don’t just close issues without making the reason transparent
On Thu, Sep 10, 2020 at 9:57 AM Xingdong Zhang [email protected] wrote:
@sujaisivanandan https://github.com/sujaisivanandan could you update the community the reason of closing the issue, fixed, not in the plan, as design, etc.?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Adobe-CEP/CEP-Resources/issues/56#issuecomment-690505593, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI4A22LWEUKFLWSRPDFNWTSFEAP3ANCNFSM4CEO5EBQ .
How do I listen for the server's event? Is there a naming convention that I have to follow and I am missing?
The manifest for my 2 extensions (Premiere Pro) looks like this (extra tags removed for readability)
client
<Extension Id="com.foo.baz.client">
<DispatchInfo>
<Resources>
<MainPath>./ui-panel/index.html</MainPath>
<ScriptPath>./host/index.jsx</ScriptPath>
</Resources>
<Lifecycle>
<AutoVisible>true</AutoVisible>
</Lifecycle>
</DispatchInfo>
</Extension>
server
<Extension Id="com.foo.baz.server">
<DispatchInfo>
<Resources>
<MainPath>./server/index.html</MainPath>
<ScriptPath>./host/server.jsx</ScriptPath>
<CEFCommandLine>
<Parameter>--enable-nodejs</Parameter>
<Parameter>--mixed-context</Parameter>
</CEFCommandLine>
</Resources>
<Lifecycle>
<AutoVisible>false</AutoVisible>
</Lifecycle>
</DispatchInfo>
</Extension>
UI Panel server start and event listener
var csinterface = new window.CSInterface();
csinterface.requestOpenExtension('com.foo.baz.server', '');
csinterface.addEventListener('com.foo.baz.server.ServerStarted', function(evt) {
console.log(evt);
});
And this is how my server.jsx
code looks like
function foo() {
const xLib = new ExternalObject("lib:PlugPlugExternalObject");
if (xLib) {
var evt = new CSXSEvent();
evt.type = 'com.foo.baz.server.ServerStarted';
evt.data = 'foo-baz-bar';
evt.dispatch();
}
}
foo();
Do I miss something? The server starts, I can debug, I can access, everything is fine but I can not receive any callback on the event listener. Thank you :D
I think you need to check if there is an error in the line "var evt = new CSXSEvent();" Although it is the official Demo code, it will report an error on my computer
Just as a note, you can actually programmatically open any extension from JSX if you're working in ILST or PHXS because you have access to Actions with Insert Menu Command (or other apps with equivalent run menu command methods). For instance, if I record an Action in ILST then Insert Menu Command to the name of the CEP extension, it will open that CEP extension. I can export it and save that aia text as a string then dynamically load it, run the Action, unload and return to my evalScript callback.
So in the case above you can associate it with a callback because your first extension can trigger it through evalScript and when the evalScript callback arrives, you'll know the extension has been opened (provided that it exists on the user's machine).