* read from the network and a corresponding message is sent back to the client.
* @throws ParentException
* @throws IOException
*/
public void startSession() throws ParentException, IOException {
Message networkMsg = null;
String networkString = serverConnection.read();
if (debug) System.err.println("NET:READ:_" + networkString + "_");
try {
networkMsg = parser.parse(networkString);
} catch (MessageParserException e) {
if (debug) System.err.println("MessageParserException: " + e.getMessage());
serverConnection.write("error, " + e.getErrorCode() + ", " + e.getMessage());
serverConnection.closeConnection();
return;
}
try {
networkMsg.accept(visitor);
if (debug) System.err.println(returnMessage.toString());
serverConnection.write(returnMessage.toString());
}
catch(SerialServerException e) {
serverConnection.write("error, " + e.getErrorCode() + ", " + e.getMessage());