Ok. I am still waiting for replies from a few people for suggestions how to get around the Event handling issue. However... Here is the problem:
1) Script compatible objects/programs use a different Dispatch handler than the IUnknown or IDispatch that normal COM does. This special handler somehow give the engine extra data on the properties, callbacks and events of the object, so that it can use them.
2) Only objects that the scripts client specifically adds to the list of available objects are bindable in the script engine.
3) Dynamically created objects, using CreateObject, cannot be bound to the scripts even handler, even if they provide this special interface.
4) If an object is not designed to work with scripting, you are screwed anyway, since you can never bind it to the script engines event handler.
Thanks Microsoft!!! This is really %#$^ convenient. lol
What this means is that for Mushclient to allow external objects to generate events, Mushclient will need some sort of internal object collection, it will have to create the objects and it will need to recieve the events and call the appropriate script routines. This isn't impossible, a single class could probably handle all of it, since in C++ you can intercept and handle events, even if you have no real idea what they where before hand. It is just a tad more complicated than I know how to manage myself, if I was coding it. ;)
But seriously, the only real solution I can see is something like adding a new feature to the plugins XML spec:
<object
name="WinAmp"
Init="winampCOM.application"
CLSID="..." <!-- Optional -->>
<Event
name="SongChange"
Params=1>
</Event>
</object>
Or something like that. In the above case, the sub would need to then be named "WinAmp_SongChange". It might need some tweaking, but the idea is to provide a collection of objects, tied to the plugin, that Mushclient can handle events from.
The only current alternative is to waste time coding a DLL or EXE that used CallPlugin and have it sit in between the client and the script. I am only guessing, but I a pretty sure that would mean also coding stuff to pass on every callback and property for the object. For something like the one above, this goes beyond silly and right into the realm of flat out stupid, since there is only the one event that needs to be captured, but about 50 commands and properties you would have to have the DLL or EXE pass on as well.
Most programs are probably like this, dozens, or even hundreds of commands, but only a handful of events that Mushclient and the scripts it runs can't respond to. Just because you 'can' use CallPlugin doesn't mean it is efficient or a completely dumb solution. :(
Anyway. It is something to consider. I still hope to find some solution, even if only an example of how to simply manage such a collection of previously unknown objects types.
1) Script compatible objects/programs use a different Dispatch handler than the IUnknown or IDispatch that normal COM does. This special handler somehow give the engine extra data on the properties, callbacks and events of the object, so that it can use them.
2) Only objects that the scripts client specifically adds to the list of available objects are bindable in the script engine.
3) Dynamically created objects, using CreateObject, cannot be bound to the scripts even handler, even if they provide this special interface.
4) If an object is not designed to work with scripting, you are screwed anyway, since you can never bind it to the script engines event handler.
Thanks Microsoft!!! This is really %#$^ convenient. lol
What this means is that for Mushclient to allow external objects to generate events, Mushclient will need some sort of internal object collection, it will have to create the objects and it will need to recieve the events and call the appropriate script routines. This isn't impossible, a single class could probably handle all of it, since in C++ you can intercept and handle events, even if you have no real idea what they where before hand. It is just a tad more complicated than I know how to manage myself, if I was coding it. ;)
But seriously, the only real solution I can see is something like adding a new feature to the plugins XML spec:
<object
name="WinAmp"
Init="winampCOM.application"
CLSID="..." <!-- Optional -->>
<Event
name="SongChange"
Params=1>
</Event>
</object>
Or something like that. In the above case, the sub would need to then be named "WinAmp_SongChange". It might need some tweaking, but the idea is to provide a collection of objects, tied to the plugin, that Mushclient can handle events from.
The only current alternative is to waste time coding a DLL or EXE that used CallPlugin and have it sit in between the client and the script. I am only guessing, but I a pretty sure that would mean also coding stuff to pass on every callback and property for the object. For something like the one above, this goes beyond silly and right into the realm of flat out stupid, since there is only the one event that needs to be captured, but about 50 commands and properties you would have to have the DLL or EXE pass on as well.
Most programs are probably like this, dozens, or even hundreds of commands, but only a handful of events that Mushclient and the scripts it runs can't respond to. Just because you 'can' use CallPlugin doesn't mean it is efficient or a completely dumb solution. :(
Anyway. It is something to consider. I still hope to find some solution, even if only an example of how to simply manage such a collection of previously unknown objects types.