diff --git a/AcaMate.xcodeproj/project.xcworkspace/xcuserdata/tanine.xcuserdatad/UserInterfaceState.xcuserstate b/AcaMate.xcodeproj/project.xcworkspace/xcuserdata/tanine.xcuserdatad/UserInterfaceState.xcuserstate index d027059..f02fd9f 100644 Binary files a/AcaMate.xcodeproj/project.xcworkspace/xcuserdata/tanine.xcuserdatad/UserInterfaceState.xcuserstate and b/AcaMate.xcodeproj/project.xcworkspace/xcuserdata/tanine.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/AcaMate.xcodeproj/xcuserdata/tanine.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/AcaMate.xcodeproj/xcuserdata/tanine.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 1bf677d..94bccea 100644 --- a/AcaMate.xcodeproj/xcuserdata/tanine.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/AcaMate.xcodeproj/xcuserdata/tanine.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -3,4 +3,114 @@ uuid = "800DD51A-C089-4DC4-AE55-7F5ABD5C0AE7" type = "1" version = "2.0"> + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AcaMate/1. View/11. Intro & Login/LoginView.swift b/AcaMate/1. View/11. Intro & Login/LoginView.swift index fa9dae9..45852ab 100644 --- a/AcaMate/1. View/11. Intro & Login/LoginView.swift +++ b/AcaMate/1. View/11. Intro & Login/LoginView.swift @@ -49,6 +49,25 @@ struct LoginView: View { } label: { makeButton(image: Image(.Logo.appleIcon), color: Color(.Text.black), "애플 계정으로 시작하기") } + + CustomTxfView(placeholder: "id", + text: $loginVM.devId, + alignment: .center, + font: .nps(size: 12)) + .frame(maxWidth: .infinity,maxHeight: 48) + .padding(EdgeInsets(top: 4, leading: 8, bottom: 4, trailing: 8)) + .background { + RoundedRectangle(cornerRadius: 24) + .foregroundStyle(Color(.Normal.light)) + }.clipped() + Button { +// loginVM.toggleLoading = true + loginVM.loginAction(type: .Dev) + + } label: { + makeButton(image: Image(.Logo.logo), + color: Color(.Text.black), "계정으로 시작하기") + } } .padding([.leading,.trailing], 28) diff --git a/AcaMate/2. Model/SNS Data.swift b/AcaMate/2. Model/SNS Data.swift index 5ff1a77..ff6d27b 100644 --- a/AcaMate/2. Model/SNS Data.swift +++ b/AcaMate/2. Model/SNS Data.swift @@ -11,6 +11,7 @@ import Foundation enum SNSLoginType: String{ case Apple = "ST00" case Kakao = "ST01" + case Dev = "ST02" } struct SNSID: Codable { diff --git a/AcaMate/3. ViewModel/LoginViewModel.swift b/AcaMate/3. ViewModel/LoginViewModel.swift index 6f50cef..9901143 100644 --- a/AcaMate/3. ViewModel/LoginViewModel.swift +++ b/AcaMate/3. ViewModel/LoginViewModel.swift @@ -20,6 +20,8 @@ class LoginViewModel: ObservableObject { @UserDefault(key: "refresh", defaultValue: "refreshToken") var refresh @UserDefault(key: "header", defaultValue: "headerValue") var headerValue + @Published var devId: String = "" + var bidArray: [String] = [] @@ -29,12 +31,13 @@ class LoginViewModel: ObservableObject { func loginAction(type: SNSLoginType) { appVM.isLoading = true - LoginController().login(type) + let acctype: String = type == .Apple ? "ST00": (type == .Kakao ? "ST01" : "ST02") + LoginController().login(type, devId) .flatMap{ snsId in self.appVM.apiManager.loadAPIData(APIRequest(path: "/api/v1/in/user/login", headers: [API_HEADER : self.headerValue], parameters: [ - "acctype": "\(type == .Apple ? "ST00": "ST01")", + "acctype": acctype, "snsId": "\(snsId.snsId)" ], decoding: APIResponse.self)) diff --git a/AcaMate/4. Controller/LoginController.swift b/AcaMate/4. Controller/LoginController.swift index 7fe292f..ac3d91b 100644 --- a/AcaMate/4. Controller/LoginController.swift +++ b/AcaMate/4. Controller/LoginController.swift @@ -16,7 +16,7 @@ import Foundation class LoginController { private var cancellables = Set() - func login(_ type: SNSLoginType) -> AnyPublisher { + func login(_ type: SNSLoginType, _ id: String = "") -> AnyPublisher { switch type { case .Kakao: return self.checkKakaoToken() @@ -32,9 +32,18 @@ class LoginController { case .Apple: return Fail(error: NSError(domain: "Apple login not implemented", code: 1, userInfo: nil)) .eraseToAnyPublisher() - + case .Dev: + return Future { promise in + var snsId = SNSID() + snsId.acctType = "dev" + snsId.snsId = "\(id)" + snsId.snsToken = "devToken" + promise(.success(snsId)) + } + .eraseToAnyPublisher() } + } func logout(type: SNSLoginType) { @@ -49,6 +58,7 @@ class LoginController { } } case .Apple: break + case .Dev: break } } } @@ -130,7 +140,7 @@ extension LoginController { if let sdkError = error as? SdkError, sdkError.isInvalidTokenError() == true { // 로그인이 필요 self.loginKakao() - // 로그인 후 동작이 sink에서 처리 될것 + // 로그인 후 동작이 sink에서 처리 될것 .sink { completion in switch completion { case .failure(let error): diff --git a/AcaMate/5. Manager/WebSocketManager.swift b/AcaMate/5. Manager/WebSocketManager.swift index 5a87c58..95693bc 100644 --- a/AcaMate/5. Manager/WebSocketManager.swift +++ b/AcaMate/5. Manager/WebSocketManager.swift @@ -53,8 +53,25 @@ class WebSocketManager: ObservableObject ,WebSocketDelegate { printLog("🆘 SOCKET ERROR: \(error?.localizedDescription ?? "unknown")") case .text(let text): + // 서버에서 메세지를 보내면 여기로 들어올거고 + // 받아온 텍스트의 앞은 target, [sendet, message] 순서로 들어온다. printLog("📩 SERVER SENT: \(text)") - receivedMessage.append(text) + + if let data = try? JSONSerialization.jsonObject(with: Data(text.utf8)) as? [String: Any], + let target = data["target"] as? String, + let args = data["arguments"] as? [String] { + + if target == "ReceiveMessage" { + let sender = args[0] + let message = args[1] + receivedMessage.append(message) + print("💬 [\(sender)] \(message)") + } + } + + + + case .binary(let binary):