Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into #380-edit-design
  • Loading branch information
godeka committed May 30, 2024
2 parents f18903c + fafcdc0 commit 07c3492
Show file tree
Hide file tree
Showing 34 changed files with 383 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public KakaoUserInfoDto getUserInfo(String accessToken) {
userInfoURI, HttpMethod.GET, request, String.class);

if (response.getStatusCode() == HttpStatus.OK) {
log.debug("kakaoResponse {}", response.getBody());
return objectMapper.readValue(response.getBody(), KakaoUserInfoDto.class);
} else {
throw new RuntimeException("Failed to retrieve user info from Kakao API");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.coffee.backend.domain.user.entity.User;
import com.coffee.backend.domain.user.repository.UserRepository;
import com.coffee.backend.domain.user.service.UserService;
import com.coffee.backend.exception.CustomException;
import com.coffee.backend.exception.ErrorCode;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -101,11 +99,12 @@ public CafeUserDto getUserInfoFromDB(Long userId) {

public void clearSessionAndCafeIdBySessionId(String sessionId) {
log.trace("clearSessionAndCafeIdBySessionId()");
User user = userRepository.findBySessionId(sessionId).orElseThrow(() -> {
Optional<User> user = userRepository.findBySessionId(sessionId);
if (user.isEmpty()) {
log.info("sessionId = {} 를 갖는 사용자가 존재하지 않습니다.", sessionId);
return new CustomException(ErrorCode.USER_NOT_FOUND);
});
// redis 에서 cafeId 유저 삭제 및 cafeId, sessionId null 로 초기화
deleteCafeChoice(user.getCafeId(), user.getUserId());
} else {
// redis 에서 cafeId 유저 삭제 및 cafeId, sessionId null 로 초기화
deleteCafeChoice(user.get().getCafeId(), user.get().getUserId());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.coffee.backend.global;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.springframework.stereotype.Component;

@Component
public class SubscriptionRegistry {
private final Map<String, Set<String>> subscriptions = new HashMap<>();

// subscribe
public synchronized void addSubscription(String sessionId, String destination) {
subscriptions.computeIfAbsent(sessionId, k -> new HashSet<>()).add(destination);
}

// 특정 세션이 특정 destination 을 구독 중인지 확인
public synchronized boolean hasSubscription(String sessionId, String destination) {
return subscriptions.containsKey(sessionId) && subscriptions.get(sessionId).contains(destination);
}

// 구독 취소
public synchronized void removeSubscription(String sessionId, String destination) {
if (subscriptions.containsKey(sessionId)) {
Set<String> destinations = subscriptions.get(sessionId);
destinations.remove(destination);
if (destinations.isEmpty()) {
subscriptions.remove(sessionId);
}
}
}

// 특정 세션의 모든 구독 취소
public synchronized void removeSubscriptionsBySessionId(String sessionId) {
subscriptions.remove(sessionId);
}

// 전체 구독 정보를 출력
public synchronized void printSubscriptions() {
System.out.println("웹소켓 구독 정보: " + subscriptions);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.coffee.backend.global;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;
import org.springframework.web.socket.messaging.SessionSubscribeEvent;
import org.springframework.web.socket.messaging.SessionUnsubscribeEvent;

@Component
public class WebSocketEventListener {
private final SubscriptionRegistry subscriptionRegistry;

@Autowired
public WebSocketEventListener(SubscriptionRegistry subscriptionRegistry) {
this.subscriptionRegistry = subscriptionRegistry;
}

// 구독 이벤트 발생 시, 구독 처리
@EventListener
public void handleSubscribeEvent(SessionSubscribeEvent event) {
StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(event.getMessage());
String sessionId = headerAccessor.getSessionId();
String destination = headerAccessor.getDestination();

// 이미 구독된 경우 pass
if (destination != null && subscriptionRegistry.hasSubscription(sessionId, destination)) {
return;
}
// 중복이 아닌 경우만 구독 추가
subscriptionRegistry.addSubscription(sessionId, destination);
subscriptionRegistry.printSubscriptions(); // 구독 정보 출력
}

// 구독 취소 이벤트 발생 시, 구독 취소 처리
@EventListener
public void handleUnsubscribeEvent(SessionUnsubscribeEvent event) {
StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(event.getMessage());
String sessionId = headerAccessor.getSessionId();
String subscriptionId = headerAccessor.getSubscriptionId();

System.out.println(
"구독 취소 이벤트 sessionId: " + sessionId + ", subscriptionId: " + subscriptionId);
// 구독 취소 시 구독 정보 삭제
subscriptionRegistry.removeSubscription(sessionId, subscriptionId);
subscriptionRegistry.printSubscriptions(); // 구독 정보 출력
}

// 웹소켓 disconnect 이벤트 발생 시, 해당 세션의 모든 구독 취소 처리
@EventListener
public void handleDisconnectEvent(SessionDisconnectEvent event) {
StompHeaderAccessor headerAccessor = StompHeaderAccessor.wrap(event.getMessage());
String sessionId = headerAccessor.getSessionId();

System.out.println("웹소켓 disconnect 이벤트 sessionId: " + sessionId);

// 연결 종료 시 모든 구독 정보 삭제
subscriptionRegistry.removeSubscriptionsBySessionId(sessionId);
subscriptionRegistry.printSubscriptions(); // 구독 정보 출력
}
}
28 changes: 26 additions & 2 deletions frontend/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ if (flutterVersionName == null) {
def googleMapApiKey = localProperties.getProperty('GOOGLE_MAP_KEY')
def kakaoNativeAppKey = localProperties.getProperty('flutter.kakao.native.appKey')

// Gradle 서명 구성
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('app/key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
namespace "com.example.frontend"
compileSdkVersion 34
Expand All @@ -51,7 +58,7 @@ android {

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.frontend"
applicationId "com.example.careercup"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 21
Expand All @@ -63,11 +70,28 @@ android {

}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}

buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug

// 소스코드 암호화
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

signingConfig signingConfigs.release
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions frontend/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-dontwarn io.flutter.embedding.**
2 changes: 1 addition & 1 deletion frontend/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<application

android:label="frontend"
android:label="커리어 한잔"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<meta-data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@mipmap/ic_launcher_adaptive_back"/>
<foreground android:drawable="@mipmap/ic_launcher_adaptive_fore"/>
</adaptive-icon>
Binary file modified frontend/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified frontend/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 18 additions & 3 deletions frontend/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -494,15 +494,20 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7G2P9R8F6L;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.frontend;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.dam.ACupOfCareer;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -677,15 +682,20 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7G2P9R8F6L;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.frontend;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.dam.ACupOfCareer;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand All @@ -700,15 +710,20 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 7G2P9R8F6L;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.frontend;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.dam.ACupOfCareer;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
5 changes: 1 addition & 4 deletions frontend/ios/Runner/Runner.entitlements
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
<dict/>
</plist>
5 changes: 4 additions & 1 deletion frontend/lib/notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:frontend/model/matching_info_model.dart';
import 'package:frontend/model/user_profile_model.dart';
import 'package:frontend/service/api_service.dart';
import 'package:frontend/widgets/dialog/notification_dialog.dart';
import 'package:frontend/widgets/user/user_details.dart';
Expand Down Expand Up @@ -99,7 +100,9 @@ class FCM {
showDialog(
context: context,
builder: (BuildContext context) {
return ReqFinishedNotification(nickname: nickname);
return ReqFinishedNotification(
nickname: nickname,
);
},
);
}
Expand Down
24 changes: 24 additions & 0 deletions frontend/lib/screen/chat_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:frontend/model/matching_info_model.dart';
import 'package:frontend/model/selected_index_model.dart';
import 'package:frontend/service/api_service.dart';
import 'package:frontend/widgets/chatting/chat_date.dart';
Expand Down Expand Up @@ -33,6 +34,7 @@ class ChatScreen extends StatefulWidget {
class _ChatScreenState extends State<ChatScreen> {
late StompClient stompClient;
final storage = const FlutterSecureStorage();
late MatchingInfoModel matchingInfo;
List<Map<String, dynamic>> chats = [];
final TextEditingController _sendingMsgController = TextEditingController();
String token = '';
Expand All @@ -41,7 +43,28 @@ class _ChatScreenState extends State<ChatScreen> {

Future<int> getChatroomId() async {
try {
// 커피챗 요청 수락
Map<String, dynamic> response = await matchAcceptRequest(widget.matchId);

// 커피챗 매칭정보 업데이트
getUserDetail().then((userDetail) {
getMatchingInfo(userDetail["data"]["userId"]).then((value) {
// 커피챗 진행중 여부 저장 - true
matchingInfo.setIsMatching(value["isMatching"]);

if (value["isMatching"]) {
matchingInfo.setMatching(
matchId: value["matchId"],
myId: value["myId"],
myNickname: value["myNickname"],
myCompany: value["myCompany"],
partnerId: value["partnerId"],
partnerCompany: value["partnerCompany"],
partnerNickname: value["partnerNickname"],
);
}
});
});
return response["data"]["chatroomId"];
} catch (e) {
// 오류 처리
Expand Down Expand Up @@ -96,6 +119,7 @@ class _ChatScreenState extends State<ChatScreen> {
@override
Widget build(BuildContext context) {
stompClient = Provider.of<StompClient>(context);
matchingInfo = Provider.of<MatchingInfoModel>(context);

return Scaffold(
appBar: ChatroomAppBar(
Expand Down
Loading

0 comments on commit 07c3492

Please sign in to comment.