3. Listener – server interaction
Listener is working like asynchronous socket server, which listens on a user defined port for incoming connections from client (shell). When connection is established, messages and data could be sent in both directions.
Listener is started when there is a command from GUI to start module with listener.
Server automatically set the port number for listener and add that info to module OPTIONS (see developers section). Listener instance, which is web socket client instance (could be several instances at once) sends the following command:
, pid – PID of the listener process. Server responses to listener with options for it and then waits for connect back.
Listener universal command:
With this command listener could receive messages from GUI, transmits them to the shell instances, or vice versa from the shell instances to the Server (Server further could send them to GUI):
action – the string (“get” or “add” values): defines whether to receive or send msg from/to GUI;
message – msg for GUI (when action=”add”);
pid – PID of the listener process,
state – listener state (None – waiting for incoming connection, 1 – shell established connection, 2 – connection closed).
Listener also has protection from “short term” connections, like connections from port scanners.