PV-WAVE Advantage > JWAVE User Guide > JWAVE Client Development > Managing the Server Connection
Managing the Server Connection
There are several useful methods in the JWaveConnection class. You can get a connection object explicitly using the JWaveConnection.getConnection method, or implicitly by constructing a JWaveExecute object (without using a JWaveConnection object in the constructor), and using that JWaveExecute.getConnecton method.
Compressing Data
Once you have a connection, you can control some of the aspects of that connection. First, if you wish to use compression in your communications with the JWAVE server, use the setCompression method. Compression can be turned on and off, allowing you to make some execute calls on a compressed connection and others without compression.
Generally, compression is beneficial for transferring large data sets (especially graphics, which are usually very compressible) over relatively slow networks. If you have a fast network connection to the server, you may not want to use compression—even for large data sets—because the CPU time of encoding and decoding the data could be inefficient. But if your network connection is slow, you may want to experiment with compression to see if it helps your performance.
Ending a JWAVE Session
When you are done with a PV‑WAVE session, you should call the
shutdown method of JWaveConnection. This closes the PV‑WAVE session, releasing any resources (memory, JWAVE licenses, and so on) that it was using on the server.
For example:
myJWaveExecute.getConnection().shutdown();
Using Multiple Clients
If you wish to have several client applications use the same PV‑WAVE session (for instance, to share data), then you need to assign that PV‑WAVE session a Session ID number (a positive integer). JWaveConnection normally acquires a unique Session ID from the server; however, if you want to use a particular PV‑WAVE session, then call setSessionID before you contact the server (using methods such as pingSession and execute). If that PV‑WAVE session is running, then you will be connected with it. If it is not running, then it will be started.
Using Ping Methods
Another set of useful methods of JWaveConnection are pingManager and
pingSession. The pingManager method allows you to make sure that the JWAVE Manager is alive, and pingSession ensures that your PV‑WAVE session has not timed out.
The pingSession method can also be used to start a PV‑WAVE session. This can help performance; for example, you may call pingSession at the beginning of your application so that the PV‑WAVE session will be activated by the time the user presses the Plot button of your GUI.
In order to keep the PV‑WAVE session alive (prevent the JWAVE Manager from killing the session if it is idle too long), use the startSessionPinger method. This method starts a thread that will call pingSession every minute (by default) until you call stopSessionPinger or shutdown. This keeps your PV‑WAVE session from becoming idle.
 
note
If you use startSessionPinger in all of your JWAVE applications, then your JWAVE Server administrator can reduce the SESSION_IDLE_TIMEOUT setting, so that idle processes can be cleaned up more often.