[gme-users] communicating with the GME environment

Kevin Smyth kevin.m.smyth at gmail.com
Wed Jun 10 15:48:54 CDT 2015


Tim,

I would warn you that this cannot be completely reliable, since you don't
know what state GME is in when you receive a message. The user could be in
the Tools>Register Components... window, or running an interpreter, or who
knows what. It is up to the user to have GME in a state that is ready for
incoming messages.

If you can live with this constraint, an add-on or interpreter can be used
for this: start a thread, and listen to your socket there. Since GME COM
objects are apartment-threaded, you cannot directly access GMEApplication
or the model from a different thread. I'd recommend one of two approaches:
1. when your addon or interpreter starts, create a hidden window, then your
thread can Post/SendMessage to that hidden window and do processing on the
main thread; 2. use CoMarshalInterThreadInterfaceInStream to pass COM
interfaces to your thread. Of course, both of these approaches require that
GME is pumping messages (e.g. not running an interpreter).

When GME is pumping messages, it is typically not in a model transaction.
But some interpreters pump messages during a transaction, so you may want
to check IMgaProject::ProjectStatus.

Kevin

On Wed, May 20, 2015 at 8:00 AM, Belschner, Tim <
tim.belschner at ils.uni-stuttgart.de> wrote:

> Hello everyone,
>
>
>
> we would like to establish a server socket or anything similar within the
> GME environment to receive commands from an external application, e.g. to
> set the focus on an atom object. Since the server socket needs to run
> continuously in the background, using an event based Add-on seems to be not
> feasible.
>
> Does anyone has a suggestion how to implement such an approach?
>
>
>
> Thanks and regards
>
> Tim
>
>
>
> _______________________________________________
> gme-users mailing list
> gme-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/cgi-bin/mailman/listinfo/gme-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.isis.vanderbilt.edu/pipermail/gme-users/attachments/20150610/15eb9337/attachment.html>


More information about the gme-users mailing list