- if (server) {
- String line;
- try {
- line = readLine(in);
- } catch (SSLException e) {
- out.write("Unauthorized\n".getBytes());
- throw e;
- }
-
- if (line != null && line.startsWith("VERSION ")) {
- // "VERSION client-version" (VERSION 1.0.0)
- Version clientVersion = new Version(
- line.substring("VERSION ".length()));
- this.clientVersion = clientVersion;
- Version v = negotiateVersion(clientVersion);
- if (v == null) {
- v = new Version();
- }
-
- sendString("VERSION " + v.toString());
- }
-
- action(clientVersion);
- } else {
- String v = sendString("VERSION " + version.toString());
- if (v != null && v.startsWith("VERSION ")) {
- v = v.substring("VERSION ".length());
- }
-
- action(new Version(v));
- }