I am modifying a JetBrains plugin. I want to add a possibility to trigger an action in the plugin (which at the time being can be triggered manually, from the “Tools” menu) with a network event, by listening to a local TCP server, and when it send an event that matches specific patter, trigger the action.
What would be the best way of implementing this? The code that I want to trigger is currently implemented as a part of an action (class that subclasses AnAction class).
I guess I should start the server with
ApplicationManager.getApplication().executeOnPooledThread(() -> { /* ... */ });
or would you recommend to use
EventQueue.invokeLater(new Thread(() -> { /* ... /* }));
instead?
The TCP client (that connect to above mentioned TCP server, and listens for a specified event) currently uses java.nio.channels.AsynchronousSocketChannel - is there a better solution for creating a non-blocking TCP client?
The TCP client currently accepts a Consumer, that is intended to invoke the mentioned action.
The work in progress code can be found in my fork: GitHub - jnareb/CodeGRITS at add-imotions-support