<div dir="ltr">Tim,<div><br></div><div>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.</div><div><br></div><div>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).<br></div><div><br></div><div>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.</div><div><br></div><div>Kevin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 20, 2015 at 8:00 AM, Belschner, Tim <span dir="ltr"><<a href="mailto:tim.belschner@ils.uni-stuttgart.de" target="_blank">tim.belschner@ils.uni-stuttgart.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="DE" link="#0563C1" vlink="#954F72"><div><p class="MsoNormal"><span lang="EN-US">Hello everyone,<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">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.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">Does anyone has a suggestion how to implement such an approach?<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">Thanks and regards<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></span></p><span class="HOEnZb"><font color="#888888"><p class="MsoNormal"><span lang="EN-US">Tim</span><span style="font-size:9.0pt;font-family:"Arial","sans-serif""><u></u><u></u></span></p><p class="MsoNormal"><u></u> <u></u></p></font></span></div></div><br>_______________________________________________<br>
gme-users mailing list<br>
<a href="mailto:gme-users@list.isis.vanderbilt.edu">gme-users@list.isis.vanderbilt.edu</a><br>
<a href="http://list.isis.vanderbilt.edu/cgi-bin/mailman/listinfo/gme-users" target="_blank">http://list.isis.vanderbilt.edu/cgi-bin/mailman/listinfo/gme-users</a><br>
<br></blockquote></div><br></div>