промежуточный. кусок рефакторинга на тему борьбы с зависаниями. пока не внедрен
This commit is contained in:
@@ -21,8 +21,8 @@ public abstract class RepositoryPass<S extends RepositoryServer, T> extends Pass
|
||||
protected ObjectInputStream in = null; // поток чтения из сокета
|
||||
protected ObjectOutputStream out = null; // поток записи в сокет
|
||||
//-
|
||||
protected ServerExchangeUnit_2021 request;
|
||||
protected ServerExchangeUnit_2021 response;
|
||||
protected ServerExchangeUnit_2021 client_request;
|
||||
protected ServerExchangeUnit_2021 server_response;
|
||||
//-
|
||||
protected Socket clientSocket = null; //сокет для общения
|
||||
protected ServerCode ExitCode = ServerCode.Undefined;
|
||||
@@ -60,12 +60,12 @@ public abstract class RepositoryPass<S extends RepositoryServer, T> extends Pass
|
||||
protected abstract void ServerAction() throws Exception;
|
||||
protected void Command(ServerExchangeUnit_2021 request_in) throws Exception {
|
||||
ExitCode = ServerCode.Undefined;
|
||||
request = request_in;
|
||||
out.writeObject(request);
|
||||
response = (ServerExchangeUnit_2021) in.readObject();
|
||||
switch (ExitCode = response.getCode()) {
|
||||
client_request = request_in;
|
||||
out.writeObject(client_request);
|
||||
server_response = (ServerExchangeUnit_2021) in.readObject();
|
||||
switch (ExitCode = server_response.getCode()) {
|
||||
case FAIL:
|
||||
throw (Exception) response.object;
|
||||
throw (Exception) server_response.object;
|
||||
case OLD:
|
||||
throw new PassException("Сервер устарел.");
|
||||
default:
|
||||
@@ -77,12 +77,12 @@ public abstract class RepositoryPass<S extends RepositoryServer, T> extends Pass
|
||||
}
|
||||
protected void ReceiveFile(String src, File dst) throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.ReceiveFile, src));
|
||||
if (response.object != null)
|
||||
response.Unpack(dst);
|
||||
if (server_response.object != null)
|
||||
server_response.Unpack(dst);
|
||||
}
|
||||
protected String ReadFile(String src) throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.ReadFile, src));
|
||||
return response.object.toString();
|
||||
return server_response.object.toString();
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user