Skip to content

Commit

Permalink
feat: HTTP controller 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
redcarrot1 committed Feb 14, 2024
1 parent ffdd9a8 commit f95caa6
Showing 1 changed file with 23 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,23 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import solution.gdsc.PathPal.domain.client.domain.Client;
import solution.gdsc.PathPal.domain.client.domain.ImageInference;
import solution.gdsc.PathPal.domain.client.repository.ClientRepository;
import solution.gdsc.PathPal.domain.client.repository.ImageInferenceRepository;
import solution.gdsc.PathPal.domain.inference.domain.Inference;
import solution.gdsc.PathPal.domain.inference.service.InferenceService;
import solution.gdsc.PathPal.domain.inference.service.SocketClient;

import javax.imageio.stream.FileImageOutputStream;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequiredArgsConstructor
public class HttpClientInferenceController {

private final SocketClient socketClient = new SocketClient("127.0.0.1", 9999, 2000);
private final InferenceService inferenceService;
private final ImageInferenceRepository imageInferenceRepository;
private final ClientRepository clientRepository;
private final int savePeriodMilliSeconds = 5000;
// private final SocketClient socketClient = new SocketClient("127.0.0.1", 9999, 2000);
// private final InferenceService inferenceService;
// private final ImageInferenceRepository imageInferenceRepository;
// private final ClientRepository clientRepository;
//private final int savePeriodMilliSeconds = 5000;
private String path = "/home/hsk4991149/static/image/";
//private String path = "/Users/hongseungtaeg/Desktop/project/GDSC-PathPal/PathPal/src/main/resources/static/";

Expand All @@ -39,22 +33,22 @@ public class HttpClientInferenceController {
public String inference(@RequestParam(name = "image") MultipartFile file,
@RequestParam(name = "time") Integer time,
HttpServletRequest request) throws Exception {
HttpSession session = request.getSession();

SessionInfo sessionInfo = sessionMap.get(session);
if (sessionInfo == null) {
int expectedSeconds = time == null ? 500 : time;
Client client = new Client(expectedSeconds);
clientRepository.save(client);

long currentTimeMillis = System.currentTimeMillis();
sessionInfo = new SessionInfo(client, currentTimeMillis, expectedSeconds);
sessionMap.put(session, sessionInfo);
}

byte[] bytes = file.getBytes();
List<Inference> inferences = socketClient.inferenceImage(bytes);
String responseMessage = inferenceService.convertInference2(inferences);
// HttpSession session = request.getSession();
//
// SessionInfo sessionInfo = sessionMap.get(session);
// if (sessionInfo == null) {
// int expectedSeconds = time == null ? 500 : time;
// Client client = new Client(expectedSeconds);
// clientRepository.save(client);
//
// long currentTimeMillis = System.currentTimeMillis();
// sessionInfo = new SessionInfo(client, currentTimeMillis, expectedSeconds);
// sessionMap.put(session, sessionInfo);
// }
//
// byte[] bytes = file.getBytes();
// List<Inference> inferences = socketClient.inferenceImage(bytes);
// String responseMessage = inferenceService.convertInference2(inferences);

// long currentTimeMillis = System.currentTimeMillis();
// if (currentTimeMillis - sessionInfo.recentlySaveTime > savePeriodMilliSeconds) {
Expand All @@ -72,6 +66,7 @@ public String inference(@RequestParam(name = "image") MultipartFile file,
// System.err.println("이미지 저장 실패");
// }
// }
return responseMessage;
// return responseMessage;
return "test";
}
}

0 comments on commit f95caa6

Please sign in to comment.