diff --git a/.gitignore b/.gitignore index fd1625e3..5b308ef4 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,7 @@ out/ ### SECRET KEY INFO ### BackEnd/src/main/resources/firebase/webrtc.json -BackEnd/src/main/resources/ssl/keystore.p12 \ No newline at end of file +BackEnd/src/main/resources/ssl/keystore.p12 + +### Xcode ### +*.xcuserstate diff --git a/iOS/.DS_Store b/iOS/.DS_Store new file mode 100644 index 00000000..ec0de071 Binary files /dev/null and b/iOS/.DS_Store differ diff --git a/iOS/Ringo/.DS_Store b/iOS/Ringo/.DS_Store new file mode 100644 index 00000000..1a9be97f Binary files /dev/null and b/iOS/Ringo/.DS_Store differ diff --git a/iOS/Ringo/Ringo.xcodeproj/project.pbxproj b/iOS/Ringo/Ringo.xcodeproj/project.pbxproj new file mode 100644 index 00000000..39b7997f --- /dev/null +++ b/iOS/Ringo/Ringo.xcodeproj/project.pbxproj @@ -0,0 +1,576 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 940C25642B73D20900E069D0 /* ConnectionCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C25632B73D20900E069D0 /* ConnectionCollectionViewCell.swift */; }; + 940C25662B74EF4D00E069D0 /* FriendService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C25652B74EF4D00E069D0 /* FriendService.swift */; }; + 940C25722B7A88FB00E069D0 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C25712B7A88FB00E069D0 /* Config.swift */; }; + 940C25782B7A899500E069D0 /* RTCStates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C25752B7A899500E069D0 /* RTCStates.swift */; }; + 940C25792B7A899500E069D0 /* SessionDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C25762B7A899500E069D0 /* SessionDescription.swift */; }; + 940C257A2B7A899500E069D0 /* IceCandidate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C25772B7A899500E069D0 /* IceCandidate.swift */; }; + 940C25832B7A89AB00E069D0 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C257C2B7A89AB00E069D0 /* Message.swift */; }; + 940C25842B7A89AB00E069D0 /* WebSocketProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C257E2B7A89AB00E069D0 /* WebSocketProvider.swift */; }; + 940C25852B7A89AB00E069D0 /* NativeWebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C257F2B7A89AB00E069D0 /* NativeWebSocket.swift */; }; + 940C25862B7A89AB00E069D0 /* StarscreamProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C25802B7A89AB00E069D0 /* StarscreamProvider.swift */; }; + 940C25872B7A89AB00E069D0 /* WebRTCClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C25812B7A89AB00E069D0 /* WebRTCClient.swift */; }; + 940C25882B7A89AB00E069D0 /* SignalingClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C25822B7A89AB00E069D0 /* SignalingClient.swift */; }; + 940C258A2B7A8FA900E069D0 /* CallService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 940C25892B7A8FA900E069D0 /* CallService.swift */; }; + 94470A8A2B71050700F0A942 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 94470A892B71050700F0A942 /* Alamofire */; }; + 94470A8D2B710A3100F0A942 /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = 94470A8C2B710A3100F0A942 /* Starscream */; }; + 94470A902B710CE500F0A942 /* WebRTC in Frameworks */ = {isa = PBXBuildFile; productRef = 94470A8F2B710CE500F0A942 /* WebRTC */; }; + 94470A932B7163E900F0A942 /* Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94470A922B7163E900F0A942 /* Model.swift */; }; + 94470A952B71680100F0A942 /* SigninService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94470A942B71680100F0A942 /* SigninService.swift */; }; + 94470A972B717DC300F0A942 /* ConnectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94470A962B717DC300F0A942 /* ConnectionViewController.swift */; }; + 945603132B6AC07D002F4B33 /* TabBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945603122B6AC07D002F4B33 /* TabBarViewController.swift */; }; + 945603152B6AC22A002F4B33 /* ContactsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945603142B6AC22A002F4B33 /* ContactsViewController.swift */; }; + 945603172B6AC2D3002F4B33 /* RecentsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945603162B6AC2D3002F4B33 /* RecentsViewController.swift */; }; + 945603192B6AC365002F4B33 /* AccountViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945603182B6AC365002F4B33 /* AccountViewController.swift */; }; + 9456031D2B6BF44A002F4B33 /* FriendRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9456031C2B6BF44A002F4B33 /* FriendRequestViewController.swift */; }; + 945603212B6D2F06002F4B33 /* Canvas.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945603202B6D2F06002F4B33 /* Canvas.swift */; }; + 945603232B6D31D9002F4B33 /* ContactsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945603222B6D31D9002F4B33 /* ContactsTableViewCell.swift */; }; + 945CF97B2B67E1CD00396E4E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945CF97A2B67E1CD00396E4E /* AppDelegate.swift */; }; + 945CF97D2B67E1CD00396E4E /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945CF97C2B67E1CD00396E4E /* SceneDelegate.swift */; }; + 945CF97F2B67E1CD00396E4E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945CF97E2B67E1CD00396E4E /* ViewController.swift */; }; + 945CF9842B67E1CE00396E4E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 945CF9832B67E1CE00396E4E /* Assets.xcassets */; }; + 945CF9872B67E1CE00396E4E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 945CF9852B67E1CE00396E4E /* LaunchScreen.storyboard */; }; + 945CF9902B69341800396E4E /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 945CF98F2B69341800396E4E /* SnapKit */; }; + 94FB0A6B2B858F66005A4915 /* TestSTTViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94FB0A6A2B858F66005A4915 /* TestSTTViewController.swift */; }; + 94FB0A6D2BAAD64A005A4915 /* TTS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94FB0A6C2BAAD64A005A4915 /* TTS.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 940C25632B73D20900E069D0 /* ConnectionCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionCollectionViewCell.swift; sourceTree = ""; }; + 940C25652B74EF4D00E069D0 /* FriendService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendService.swift; sourceTree = ""; }; + 940C25712B7A88FB00E069D0 /* Config.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = ""; }; + 940C25752B7A899500E069D0 /* RTCStates.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RTCStates.swift; sourceTree = ""; }; + 940C25762B7A899500E069D0 /* SessionDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SessionDescription.swift; sourceTree = ""; }; + 940C25772B7A899500E069D0 /* IceCandidate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IceCandidate.swift; sourceTree = ""; }; + 940C257C2B7A89AB00E069D0 /* Message.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = ""; }; + 940C257E2B7A89AB00E069D0 /* WebSocketProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebSocketProvider.swift; sourceTree = ""; }; + 940C257F2B7A89AB00E069D0 /* NativeWebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NativeWebSocket.swift; sourceTree = ""; }; + 940C25802B7A89AB00E069D0 /* StarscreamProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StarscreamProvider.swift; sourceTree = ""; }; + 940C25812B7A89AB00E069D0 /* WebRTCClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebRTCClient.swift; sourceTree = ""; }; + 940C25822B7A89AB00E069D0 /* SignalingClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignalingClient.swift; sourceTree = ""; }; + 940C25892B7A8FA900E069D0 /* CallService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallService.swift; sourceTree = ""; }; + 94470A922B7163E900F0A942 /* Model.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Model.swift; sourceTree = ""; }; + 94470A942B71680100F0A942 /* SigninService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SigninService.swift; sourceTree = ""; }; + 94470A962B717DC300F0A942 /* ConnectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionViewController.swift; sourceTree = ""; }; + 945603122B6AC07D002F4B33 /* TabBarViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarViewController.swift; sourceTree = ""; }; + 945603142B6AC22A002F4B33 /* ContactsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsViewController.swift; sourceTree = ""; }; + 945603162B6AC2D3002F4B33 /* RecentsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentsViewController.swift; sourceTree = ""; }; + 945603182B6AC365002F4B33 /* AccountViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountViewController.swift; sourceTree = ""; }; + 9456031C2B6BF44A002F4B33 /* FriendRequestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FriendRequestViewController.swift; sourceTree = ""; }; + 945603202B6D2F06002F4B33 /* Canvas.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Canvas.swift; sourceTree = ""; }; + 945603222B6D31D9002F4B33 /* ContactsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsTableViewCell.swift; sourceTree = ""; }; + 945CF9772B67E1CD00396E4E /* Ringo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Ringo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 945CF97A2B67E1CD00396E4E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 945CF97C2B67E1CD00396E4E /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 945CF97E2B67E1CD00396E4E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 945CF9832B67E1CE00396E4E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 945CF9862B67E1CE00396E4E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 945CF9882B67E1CE00396E4E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 94FB0A6A2B858F66005A4915 /* TestSTTViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSTTViewController.swift; sourceTree = ""; }; + 94FB0A6C2BAAD64A005A4915 /* TTS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TTS.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 945CF9742B67E1CD00396E4E /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 945CF9902B69341800396E4E /* SnapKit in Frameworks */, + 94470A902B710CE500F0A942 /* WebRTC in Frameworks */, + 94470A8A2B71050700F0A942 /* Alamofire in Frameworks */, + 94470A8D2B710A3100F0A942 /* Starscream in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 940C256A2B79EC5700E069D0 /* WebRTC */ = { + isa = PBXGroup; + children = ( + 940C257B2B7A89AB00E069D0 /* Services */, + 940C25742B7A899500E069D0 /* Extensions */, + 940C25712B7A88FB00E069D0 /* Config.swift */, + 940C25892B7A8FA900E069D0 /* CallService.swift */, + ); + path = WebRTC; + sourceTree = ""; + }; + 940C25742B7A899500E069D0 /* Extensions */ = { + isa = PBXGroup; + children = ( + 940C25752B7A899500E069D0 /* RTCStates.swift */, + 940C25762B7A899500E069D0 /* SessionDescription.swift */, + 940C25772B7A899500E069D0 /* IceCandidate.swift */, + ); + path = Extensions; + sourceTree = ""; + }; + 940C257B2B7A89AB00E069D0 /* Services */ = { + isa = PBXGroup; + children = ( + 940C257C2B7A89AB00E069D0 /* Message.swift */, + 940C257D2B7A89AB00E069D0 /* WebSocketProvider */, + 940C25812B7A89AB00E069D0 /* WebRTCClient.swift */, + 940C25822B7A89AB00E069D0 /* SignalingClient.swift */, + ); + path = Services; + sourceTree = ""; + }; + 940C257D2B7A89AB00E069D0 /* WebSocketProvider */ = { + isa = PBXGroup; + children = ( + 940C257E2B7A89AB00E069D0 /* WebSocketProvider.swift */, + 940C257F2B7A89AB00E069D0 /* NativeWebSocket.swift */, + 940C25802B7A89AB00E069D0 /* StarscreamProvider.swift */, + ); + path = WebSocketProvider; + sourceTree = ""; + }; + 94470A912B71157C00F0A942 /* Screens */ = { + isa = PBXGroup; + children = ( + 945CF97E2B67E1CD00396E4E /* ViewController.swift */, + 945603122B6AC07D002F4B33 /* TabBarViewController.swift */, + 945603142B6AC22A002F4B33 /* ContactsViewController.swift */, + 9456031C2B6BF44A002F4B33 /* FriendRequestViewController.swift */, + 945603162B6AC2D3002F4B33 /* RecentsViewController.swift */, + 945603182B6AC365002F4B33 /* AccountViewController.swift */, + ); + path = Screens; + sourceTree = ""; + }; + 945CF96E2B67E1CD00396E4E = { + isa = PBXGroup; + children = ( + 945CF9792B67E1CD00396E4E /* Ringo */, + 945CF9782B67E1CD00396E4E /* Products */, + ); + sourceTree = ""; + }; + 945CF9782B67E1CD00396E4E /* Products */ = { + isa = PBXGroup; + children = ( + 945CF9772B67E1CD00396E4E /* Ringo.app */, + ); + name = Products; + sourceTree = ""; + }; + 945CF9792B67E1CD00396E4E /* Ringo */ = { + isa = PBXGroup; + children = ( + 940C256A2B79EC5700E069D0 /* WebRTC */, + 94470A912B71157C00F0A942 /* Screens */, + 945CF97A2B67E1CD00396E4E /* AppDelegate.swift */, + 945CF97C2B67E1CD00396E4E /* SceneDelegate.swift */, + 940C25632B73D20900E069D0 /* ConnectionCollectionViewCell.swift */, + 945603222B6D31D9002F4B33 /* ContactsTableViewCell.swift */, + 94470A922B7163E900F0A942 /* Model.swift */, + 94470A942B71680100F0A942 /* SigninService.swift */, + 940C25652B74EF4D00E069D0 /* FriendService.swift */, + 94470A962B717DC300F0A942 /* ConnectionViewController.swift */, + 94FB0A6A2B858F66005A4915 /* TestSTTViewController.swift */, + 94FB0A6C2BAAD64A005A4915 /* TTS.swift */, + 945603202B6D2F06002F4B33 /* Canvas.swift */, + 945CF9832B67E1CE00396E4E /* Assets.xcassets */, + 945CF9852B67E1CE00396E4E /* LaunchScreen.storyboard */, + 945CF9882B67E1CE00396E4E /* Info.plist */, + ); + path = Ringo; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 945CF9762B67E1CD00396E4E /* Ringo */ = { + isa = PBXNativeTarget; + buildConfigurationList = 945CF98B2B67E1CE00396E4E /* Build configuration list for PBXNativeTarget "Ringo" */; + buildPhases = ( + 945CF9732B67E1CD00396E4E /* Sources */, + 945CF9742B67E1CD00396E4E /* Frameworks */, + 945CF9752B67E1CD00396E4E /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Ringo; + packageProductDependencies = ( + 945CF98F2B69341800396E4E /* SnapKit */, + 94470A892B71050700F0A942 /* Alamofire */, + 94470A8C2B710A3100F0A942 /* Starscream */, + 94470A8F2B710CE500F0A942 /* WebRTC */, + ); + productName = Ringo; + productReference = 945CF9772B67E1CD00396E4E /* Ringo.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 945CF96F2B67E1CD00396E4E /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1510; + LastUpgradeCheck = 1510; + TargetAttributes = { + 945CF9762B67E1CD00396E4E = { + CreatedOnToolsVersion = 15.1; + }; + }; + }; + buildConfigurationList = 945CF9722B67E1CD00396E4E /* Build configuration list for PBXProject "Ringo" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 945CF96E2B67E1CD00396E4E; + packageReferences = ( + 945CF98E2B69341800396E4E /* XCRemoteSwiftPackageReference "SnapKit" */, + 94470A882B71050700F0A942 /* XCRemoteSwiftPackageReference "Alamofire" */, + 94470A8B2B710A3100F0A942 /* XCRemoteSwiftPackageReference "Starscream" */, + 94470A8E2B710CE500F0A942 /* XCRemoteSwiftPackageReference "WebRTC" */, + ); + productRefGroup = 945CF9782B67E1CD00396E4E /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 945CF9762B67E1CD00396E4E /* Ringo */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 945CF9752B67E1CD00396E4E /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 945CF9872B67E1CE00396E4E /* LaunchScreen.storyboard in Resources */, + 945CF9842B67E1CE00396E4E /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 945CF9732B67E1CD00396E4E /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 945603212B6D2F06002F4B33 /* Canvas.swift in Sources */, + 94470A972B717DC300F0A942 /* ConnectionViewController.swift in Sources */, + 945603132B6AC07D002F4B33 /* TabBarViewController.swift in Sources */, + 940C25782B7A899500E069D0 /* RTCStates.swift in Sources */, + 940C25852B7A89AB00E069D0 /* NativeWebSocket.swift in Sources */, + 945CF97F2B67E1CD00396E4E /* ViewController.swift in Sources */, + 940C25642B73D20900E069D0 /* ConnectionCollectionViewCell.swift in Sources */, + 94FB0A6D2BAAD64A005A4915 /* TTS.swift in Sources */, + 940C257A2B7A899500E069D0 /* IceCandidate.swift in Sources */, + 945603192B6AC365002F4B33 /* AccountViewController.swift in Sources */, + 940C258A2B7A8FA900E069D0 /* CallService.swift in Sources */, + 945CF97B2B67E1CD00396E4E /* AppDelegate.swift in Sources */, + 945603172B6AC2D3002F4B33 /* RecentsViewController.swift in Sources */, + 940C25872B7A89AB00E069D0 /* WebRTCClient.swift in Sources */, + 94FB0A6B2B858F66005A4915 /* TestSTTViewController.swift in Sources */, + 945603232B6D31D9002F4B33 /* ContactsTableViewCell.swift in Sources */, + 945CF97D2B67E1CD00396E4E /* SceneDelegate.swift in Sources */, + 94470A932B7163E900F0A942 /* Model.swift in Sources */, + 940C25662B74EF4D00E069D0 /* FriendService.swift in Sources */, + 940C25792B7A899500E069D0 /* SessionDescription.swift in Sources */, + 945603152B6AC22A002F4B33 /* ContactsViewController.swift in Sources */, + 940C25722B7A88FB00E069D0 /* Config.swift in Sources */, + 940C25842B7A89AB00E069D0 /* WebSocketProvider.swift in Sources */, + 940C25882B7A89AB00E069D0 /* SignalingClient.swift in Sources */, + 940C25832B7A89AB00E069D0 /* Message.swift in Sources */, + 940C25862B7A89AB00E069D0 /* StarscreamProvider.swift in Sources */, + 9456031D2B6BF44A002F4B33 /* FriendRequestViewController.swift in Sources */, + 94470A952B71680100F0A942 /* SigninService.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 945CF9852B67E1CE00396E4E /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 945CF9862B67E1CE00396E4E /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 945CF9892B67E1CE00396E4E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 945CF98A2B67E1CE00396E4E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 945CF98C2B67E1CE00396E4E /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = L2MRZPUQGZ; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = Ringo/Info.plist; + INFOPLIST_KEY_NSMicrophoneUsageDescription = "Need microphone access for use device's mic"; + INFOPLIST_KEY_NSSpeechRecognitionUsageDescription = "Speech recognition will be used to determine which words you speak into the device's microphone."; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.tukcomCD2024.Ringo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 945CF98D2B67E1CE00396E4E /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = L2MRZPUQGZ; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = Ringo/Info.plist; + INFOPLIST_KEY_NSMicrophoneUsageDescription = "Need microphone access for use device's mic"; + INFOPLIST_KEY_NSSpeechRecognitionUsageDescription = "Speech recognition will be used to determine which words you speak into the device's microphone."; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.tukcomCD2024.Ringo; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 945CF9722B67E1CD00396E4E /* Build configuration list for PBXProject "Ringo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 945CF9892B67E1CE00396E4E /* Debug */, + 945CF98A2B67E1CE00396E4E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 945CF98B2B67E1CE00396E4E /* Build configuration list for PBXNativeTarget "Ringo" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 945CF98C2B67E1CE00396E4E /* Debug */, + 945CF98D2B67E1CE00396E4E /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 94470A882B71050700F0A942 /* XCRemoteSwiftPackageReference "Alamofire" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/Alamofire/Alamofire.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.8.1; + }; + }; + 94470A8B2B710A3100F0A942 /* XCRemoteSwiftPackageReference "Starscream" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/daltoniam/Starscream.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 4.0.6; + }; + }; + 94470A8E2B710CE500F0A942 /* XCRemoteSwiftPackageReference "WebRTC" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/stasel/WebRTC.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 120.0.0; + }; + }; + 945CF98E2B69341800396E4E /* XCRemoteSwiftPackageReference "SnapKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SnapKit/SnapKit.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.7.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 94470A892B71050700F0A942 /* Alamofire */ = { + isa = XCSwiftPackageProductDependency; + package = 94470A882B71050700F0A942 /* XCRemoteSwiftPackageReference "Alamofire" */; + productName = Alamofire; + }; + 94470A8C2B710A3100F0A942 /* Starscream */ = { + isa = XCSwiftPackageProductDependency; + package = 94470A8B2B710A3100F0A942 /* XCRemoteSwiftPackageReference "Starscream" */; + productName = Starscream; + }; + 94470A8F2B710CE500F0A942 /* WebRTC */ = { + isa = XCSwiftPackageProductDependency; + package = 94470A8E2B710CE500F0A942 /* XCRemoteSwiftPackageReference "WebRTC" */; + productName = WebRTC; + }; + 945CF98F2B69341800396E4E /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + package = 945CF98E2B69341800396E4E /* XCRemoteSwiftPackageReference "SnapKit" */; + productName = SnapKit; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 945CF96F2B67E1CD00396E4E /* Project object */; +} diff --git a/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..0c67376e --- /dev/null +++ b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,5 @@ + + + + + diff --git a/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 00000000..a0c7c439 --- /dev/null +++ b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,41 @@ +{ + "pins" : [ + { + "identity" : "alamofire", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Alamofire/Alamofire.git", + "state" : { + "revision" : "3dc6a42c7727c49bf26508e29b0a0b35f9c7e1ad", + "version" : "5.8.1" + } + }, + { + "identity" : "snapkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/SnapKit/SnapKit.git", + "state" : { + "revision" : "e74fe2a978d1216c3602b129447c7301573cc2d8", + "version" : "5.7.0" + } + }, + { + "identity" : "starscream", + "kind" : "remoteSourceControl", + "location" : "https://github.com/daltoniam/Starscream.git", + "state" : { + "revision" : "ac6c0fc9da221873e01bd1a0d4818498a71eef33", + "version" : "4.0.6" + } + }, + { + "identity" : "webrtc", + "kind" : "remoteSourceControl", + "location" : "https://github.com/stasel/WebRTC.git", + "state" : { + "revision" : "3edaa8f0ddae889ad8ea236023de88672f6a16ec", + "version" : "120.0.0" + } + } + ], + "version" : 2 +} diff --git a/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcuserdata/jinhyuk.xcuserdatad/Bookmarks/bookmarks.plist b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcuserdata/jinhyuk.xcuserdatad/Bookmarks/bookmarks.plist new file mode 100644 index 00000000..c8d4f0ab --- /dev/null +++ b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcuserdata/jinhyuk.xcuserdatad/Bookmarks/bookmarks.plist @@ -0,0 +1,8 @@ + + + + + top-level-items + + + diff --git a/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcuserdata/jinhyuk.xcuserdatad/UserInterfaceState.xcuserstate b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcuserdata/jinhyuk.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000..e16ba19b Binary files /dev/null and b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcuserdata/jinhyuk.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcuserdata/jinhyuk.xcuserdatad/WorkspaceSettings.xcsettings b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcuserdata/jinhyuk.xcuserdatad/WorkspaceSettings.xcsettings new file mode 100644 index 00000000..bbfef027 --- /dev/null +++ b/iOS/Ringo/Ringo.xcodeproj/project.xcworkspace/xcuserdata/jinhyuk.xcuserdatad/WorkspaceSettings.xcsettings @@ -0,0 +1,14 @@ + + + + + BuildLocationStyle + UseAppPreferences + CustomBuildLocationType + RelativeToDerivedData + DerivedDataLocationStyle + Default + ShowSharedSchemesAutomaticallyEnabled + + + diff --git a/iOS/Ringo/Ringo.xcodeproj/xcuserdata/jinhyuk.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/iOS/Ringo/Ringo.xcodeproj/xcuserdata/jinhyuk.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 00000000..42a90323 --- /dev/null +++ b/iOS/Ringo/Ringo.xcodeproj/xcuserdata/jinhyuk.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,40 @@ + + + + + + + + + + + + + diff --git a/iOS/Ringo/Ringo.xcodeproj/xcuserdata/jinhyuk.xcuserdatad/xcschemes/xcschememanagement.plist b/iOS/Ringo/Ringo.xcodeproj/xcuserdata/jinhyuk.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..a56ab3eb --- /dev/null +++ b/iOS/Ringo/Ringo.xcodeproj/xcuserdata/jinhyuk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,35 @@ + + + + + SchemeUserState + + Ringo.xcscheme_^#shared#^_ + + orderHint + 0 + + SnapKitPlayground (Playground) 1.xcscheme + + isShown + + orderHint + 2 + + SnapKitPlayground (Playground) 2.xcscheme + + isShown + + orderHint + 3 + + SnapKitPlayground (Playground).xcscheme + + isShown + + orderHint + 0 + + + + diff --git a/iOS/Ringo/Ringo/.DS_Store b/iOS/Ringo/Ringo/.DS_Store new file mode 100644 index 00000000..642c9ec0 Binary files /dev/null and b/iOS/Ringo/Ringo/.DS_Store differ diff --git a/iOS/Ringo/Ringo/AppDelegate.swift b/iOS/Ringo/Ringo/AppDelegate.swift new file mode 100644 index 00000000..68ce73de --- /dev/null +++ b/iOS/Ringo/Ringo/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// Ringo +// +// Created by 강진혁 on 1/29/24. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/iOS/Ringo/Ringo/Assets.xcassets/AccentColor.colorset/Contents.json b/iOS/Ringo/Ringo/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/iOS/Ringo/Ringo/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS/Ringo/Ringo/Assets.xcassets/AppIcon.appiconset/Contents.json b/iOS/Ringo/Ringo/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..13613e3e --- /dev/null +++ b/iOS/Ringo/Ringo/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/Contents.json b/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/Contents.json new file mode 100644 index 00000000..7cd212e1 --- /dev/null +++ b/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "apple-3.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "apple-2.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "apple.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/apple-2.png b/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/apple-2.png new file mode 100644 index 00000000..d35dd761 Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/apple-2.png differ diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/apple-3.png b/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/apple-3.png new file mode 100644 index 00000000..f7aaaf55 Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/apple-3.png differ diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/apple.png b/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/apple.png new file mode 100644 index 00000000..1a180db3 Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/Apple.imageset/apple.png differ diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Contents.json b/iOS/Ringo/Ringo/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/iOS/Ringo/Ringo/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Contents.json b/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Contents.json new file mode 100644 index 00000000..aaf5e678 --- /dev/null +++ b/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "Facebook-3.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Facebook-2.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Facebook.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Facebook-2.png b/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Facebook-2.png new file mode 100644 index 00000000..dedfc4ac Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Facebook-2.png differ diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Facebook-3.png b/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Facebook-3.png new file mode 100644 index 00000000..db20d957 Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Facebook-3.png differ diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Facebook.png b/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Facebook.png new file mode 100644 index 00000000..2f6d212f Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/Facebook.imageset/Facebook.png differ diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/Contents.json b/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/Contents.json new file mode 100644 index 00000000..83cd9ec8 --- /dev/null +++ b/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "google-3.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "google-2.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "google.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/google-2.png b/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/google-2.png new file mode 100644 index 00000000..2244131a Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/google-2.png differ diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/google-3.png b/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/google-3.png new file mode 100644 index 00000000..05c33ca4 Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/google-3.png differ diff --git a/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/google.png b/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/google.png new file mode 100644 index 00000000..3b0351e2 Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/Google.imageset/google.png differ diff --git a/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/Contents.json b/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/Contents.json new file mode 100644 index 00000000..b0a6174f --- /dev/null +++ b/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/Contents.json @@ -0,0 +1,26 @@ +{ + "images" : [ + { + "filename" : "translate_1375510.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "translate_1375510 1.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "translate_1375510 2.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "template-rendering-intent" : "original" + } +} diff --git a/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/translate_1375510 1.png b/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/translate_1375510 1.png new file mode 100644 index 00000000..54643334 Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/translate_1375510 1.png differ diff --git a/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/translate_1375510 2.png b/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/translate_1375510 2.png new file mode 100644 index 00000000..54643334 Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/translate_1375510 2.png differ diff --git a/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/translate_1375510.png b/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/translate_1375510.png new file mode 100644 index 00000000..54643334 Binary files /dev/null and b/iOS/Ringo/Ringo/Assets.xcassets/translate.imageset/translate_1375510.png differ diff --git a/iOS/Ringo/Ringo/Base.lproj/LaunchScreen.storyboard b/iOS/Ringo/Ringo/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/iOS/Ringo/Ringo/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/Ringo/Ringo/Canvas.swift b/iOS/Ringo/Ringo/Canvas.swift new file mode 100644 index 00000000..e49aad96 --- /dev/null +++ b/iOS/Ringo/Ringo/Canvas.swift @@ -0,0 +1,26 @@ +// +// Canvas.swift +// Ringo +// +// Created by 강진혁 on 2/2/24. +// + +// canvas 이용하기 +import SwiftUI + +extension UIViewController { + private struct Preview: UIViewControllerRepresentable { + let viewController: UIViewController + + func makeUIViewController(context: Context) -> UIViewController { + return viewController + } + + func updateUIViewController(_ uiViewController: UIViewController, context: Context) { + } + } + + func toPreview() -> some View { + Preview(viewController: self).edgesIgnoringSafeArea(/*@START_MENU_TOKEN@*/.all/*@END_MENU_TOKEN@*/) + } +} diff --git a/iOS/Ringo/Ringo/ConnectionCollectionViewCell.swift b/iOS/Ringo/Ringo/ConnectionCollectionViewCell.swift new file mode 100644 index 00000000..189d1818 --- /dev/null +++ b/iOS/Ringo/Ringo/ConnectionCollectionViewCell.swift @@ -0,0 +1,79 @@ +// +// ConnectionCollectionViewCell.swift +// Ringo +// +// Created by 강진혁 on 2/7/24. +// + +import UIKit +import SnapKit + +class ConnectionCollectionViewCell: UICollectionViewCell { + + static let identifier = "ConnectionCollectionViewCell" + var nameLabel = UILabel() + + required init?(coder: NSCoder) { + super.init(coder: coder) + setUpView() + setUpValue() + setConstraints() + } + + override init(frame: CGRect) { + super.init(frame: .zero) + setUpView() + setUpValue() + setConstraints() + } + + func setUpView() { + contentView.addSubview(nameLabel) + } + + func setUpValue() { + nameLabel.text = "name" + nameLabel.textColor = .white + nameLabel.font = .preferredFont(forTextStyle: .title2) + nameLabel.textAlignment = .center + nameLabel.backgroundColor = .black.withAlphaComponent(0.5) + nameLabel.layer.cornerRadius = 15 + nameLabel.clipsToBounds = true + +// nameLabel.layer.borderColor = UIColor.systemGreen.cgColor +// nameLabel.layer.borderWidth = 2 + } + + func setConstraints() { + nameLabel.snp.makeConstraints { make in + make.edges.equalTo(contentView.safeAreaLayoutGuide) + } + } +} +// MARK: - canvas 이용하기 +import SwiftUI +struct ConnectionViewCellPreview: UIViewRepresentable { +let view: View + +init(_ builder: @escaping () -> View) { + view = builder() +} + +func makeUIView(context: Context) -> UIView { + return view +} + +func updateUIView(_ view: UIView, context: Context) { + view.setContentHuggingPriority(.defaultHigh, for: .horizontal) + view.setContentHuggingPriority(.defaultHigh, for: .vertical) +} +} + +struct ConnectionCollectionViewCellPreview: PreviewProvider{ +static var previews: some View { + UIViewPreview { + let button = ConnectionCollectionViewCell(frame: .zero) + return button + } +} +} diff --git a/iOS/Ringo/Ringo/ConnectionViewController.swift b/iOS/Ringo/Ringo/ConnectionViewController.swift new file mode 100644 index 00000000..988e35f2 --- /dev/null +++ b/iOS/Ringo/Ringo/ConnectionViewController.swift @@ -0,0 +1,222 @@ +// +// ConnectionViewController.swift +// Ringo +// +// Created by 강진혁 on 2/6/24. +// + +import UIKit +import SnapKit + +class ConnectionViewController: UIViewController { + + let connectionCollectionViewCell = ConnectionCollectionViewCell.identifier + let gradientLayer = CAGradientLayer() + let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + let vStack = UIStackView() + let hStack1 = UIStackView() + let hStack2 = UIStackView() + let muteBtn = UIButton() + let speakerBtn = UIButton() + let translateBtn = UIButton() + let hangUpBtn = UIButton() + + let randomNames = ["example"] + + override func viewDidLoad() { + super.viewDidLoad() + setUpView() + setUpValue() + setConstraints() + } + + func setUpView() { + view.layer.addSublayer(gradientLayer) + view.addSubview(collectionView) + view.addSubview(vStack) + vStack.addArrangedSubview(hStack1) + vStack.addArrangedSubview(hStack2) + hStack1.addArrangedSubview(muteBtn) + hStack1.addArrangedSubview(speakerBtn) + hStack1.addArrangedSubview(translateBtn) + hStack2.addArrangedSubview(hangUpBtn) + } + + func setUpValue() { + view.backgroundColor = .clear + gradientLayer.frame = view.bounds + gradientLayer.type = .radial + gradientLayer.startPoint = CGPoint(x: -0.3, y: -0.15) + gradientLayer.endPoint = CGPoint(x: 2.0, y: 1.0) + gradientLayer.locations = [0,0.1,0.8,1] + gradientLayer.colors = [ + CGColor(red: 111/255.0, green: 122/255.0, blue: 130/255.0, alpha: 1), + CGColor(red: 93/255.0, green: 114/255.0, blue: 126/255.0, alpha: 1), + CGColor(red: 17/255.0, green: 43/255.0, blue: 74/255.0, alpha: 1), + CGColor(red: 13/255.0, green: 36/255.0, blue: 69/255.0, alpha: 1) + ] + + collectionView.register(ConnectionCollectionViewCell.self, forCellWithReuseIdentifier: connectionCollectionViewCell) + collectionView.delegate = self + collectionView.dataSource = self + collectionView.backgroundColor = .clear + + vStack.layoutMargins = UIEdgeInsets(top: 30, left: 40, bottom: 30, right: 40) + vStack.isLayoutMarginsRelativeArrangement = true + vStack.axis = .vertical + vStack.alignment = .center + vStack.distribution = .fillEqually + vStack.spacing = 40 + + hStack1.axis = .horizontal + hStack1.alignment = .center + hStack1.distribution = .equalCentering + + let imageSize = UIImage.SymbolConfiguration(font: .systemFont(ofSize: 25)) + + muteBtn.backgroundColor = .white.withAlphaComponent(0.16) + muteBtn.tintColor = .white + muteBtn.configuration = .plain() + muteBtn.setImage(UIImage(systemName: "mic.slash.fill",withConfiguration: imageSize), for: .normal) + muteBtn.clipsToBounds = true + muteBtn.invalidateIntrinsicContentSize() + muteBtn.configuration?.contentInsets = NSDirectionalEdgeInsets(top: 25, leading: 25, bottom: 25, trailing: 25) + muteBtn.layer.cornerRadius = 40 + + speakerBtn.backgroundColor = .white.withAlphaComponent(0.16) + speakerBtn.tintColor = .white + speakerBtn.configuration = .plain() + speakerBtn.setImage(UIImage(systemName: "speaker.wave.3.fill",withConfiguration: imageSize), for: .normal) + speakerBtn.clipsToBounds = true + speakerBtn.invalidateIntrinsicContentSize() + speakerBtn.configuration?.contentInsets = NSDirectionalEdgeInsets(top: 25, leading: 15, bottom: 25, trailing: 15) + speakerBtn.layer.cornerRadius = 40 + + translateBtn.backgroundColor = .white.withAlphaComponent(0.16) + translateBtn.tintColor = .white + translateBtn.configuration = .plain() + translateBtn.setImage(UIImage(systemName: "character.book.closed.fill",withConfiguration: imageSize), for: .normal) + translateBtn.clipsToBounds = true + translateBtn.invalidateIntrinsicContentSize() + translateBtn.configuration?.contentInsets = NSDirectionalEdgeInsets(top: 25, leading: 23, bottom: 25, trailing: 23) + translateBtn.layer.cornerRadius = 40 + translateBtn.addTarget(self, action: #selector(pressedTransBtn), for: .touchUpInside) + + hStack2.axis = .horizontal + hStack2.alignment = .center + hStack2.distribution = .equalCentering + + hangUpBtn.backgroundColor = .systemRed + hangUpBtn.tintColor = .white + hangUpBtn.configuration = .plain() + hangUpBtn.setImage(UIImage(systemName: "phone.down.fill",withConfiguration: UIImage.SymbolConfiguration(font: .systemFont(ofSize: 30))), for: .normal) + hangUpBtn.clipsToBounds = true + hangUpBtn.invalidateIntrinsicContentSize() + hangUpBtn.configuration?.contentInsets = NSDirectionalEdgeInsets(top: 25, leading: 16, bottom: 25, trailing: 16) + hangUpBtn.layer.cornerRadius = 40 + hangUpBtn.addTarget(self, action: #selector(hangUpBtnAction), for: .touchUpInside) + } + + func setConstraints() { + collectionView.snp.makeConstraints { make in + make.top.equalTo(view.safeAreaLayoutGuide) + make.horizontalEdges.equalTo(view.safeAreaLayoutGuide) + make.height.equalTo(view.safeAreaLayoutGuide).multipliedBy(0.65) + } + vStack.snp.makeConstraints { make in + make.top.equalTo(collectionView.snp.bottom) + make.bottom.equalTo(view.safeAreaLayoutGuide) + make.horizontalEdges.equalTo(view.safeAreaLayoutGuide) + } + hStack1.snp.makeConstraints { make in + make.horizontalEdges.equalTo(vStack.layoutMarginsGuide) + } + + } + + @objc func hangUpBtnAction() { + CallService.shared.webRTCClient.endCall() + dismiss(animated: true) + } + + @objc func pressedTransBtn() { + let sttVC = TestSTTViewController() + sttVC.modalPresentationStyle = .automatic + present(sttVC, animated: true,completion: nil) + } + +} +//MARK: - CollectionViewDelegate +extension ConnectionViewController: UICollectionViewDelegate { + +} +//MARK: - CollectionViewDataSource +extension ConnectionViewController: UICollectionViewDataSource { + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return randomNames.count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: connectionCollectionViewCell, for: indexPath) as! ConnectionCollectionViewCell + cell.nameLabel.text = randomNames[indexPath.row] + + return cell + } + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { + //6개까지 커버 + var cellWidth = 300 + switch randomNames.count { + case 5...: + cellWidth = Int((collectionView.frame.width - (40 * 2) - 20)/2) + return CGSize(width: cellWidth, height: Int((collectionView.frame.height - (60 * 2))/3)) + case 3..<5: + cellWidth = Int((collectionView.frame.width - (40 * 2) - 20)/2) + collectionView.contentInset.top = ((collectionView.frame.height/2) - 50 - CGFloat(cellWidth)) + return CGSize(width: cellWidth, height: cellWidth) + default: + cellWidth = Int((collectionView.frame.width - (40 * 2))) + if randomNames.count == 1 { + collectionView.contentInset.top = ((collectionView.frame.height/2) - 40 - CGFloat(cellWidth/4)) + } else { + collectionView.contentInset.top = ((collectionView.frame.height/2) - 50 - CGFloat(cellWidth/2)) + } + return CGSize(width: cellWidth, height: cellWidth/2) + } + } +} + +//MARK: - cell layout +extension ConnectionViewController: UICollectionViewDelegateFlowLayout { + + // 위 아래 간격 + func collectionView( + _ collectionView: UICollectionView, + layout collectionViewLayout: UICollectionViewLayout, + minimumLineSpacingForSectionAt section: Int + ) -> CGFloat { + return 20 + } + + // 옆 간격 + func collectionView( + _ collectionView: UICollectionView, + layout collectionViewLayout: UICollectionViewLayout, + minimumInteritemSpacingForSectionAt section: Int + ) -> CGFloat { + return 20 + } + + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { + return UIEdgeInsets(top: 40, left: 40, bottom: 40, right: 40) + } +} + +// MARK: - canvas 이용하기 +import SwiftUI +@available(iOS 13.0.0, *) +struct ConnectionViewPreview: PreviewProvider { + static var previews: some View { + ConnectionViewController().toPreview() + } +} diff --git a/iOS/Ringo/Ringo/ContactsTableViewCell.swift b/iOS/Ringo/Ringo/ContactsTableViewCell.swift new file mode 100644 index 00000000..42a027b8 --- /dev/null +++ b/iOS/Ringo/Ringo/ContactsTableViewCell.swift @@ -0,0 +1,190 @@ +// +// ContactsTableViewCell.swift +// Ringo +// +// Created by 강진혁 on 2/2/24. +// + +import UIKit +import SnapKit + +protocol ContactsTableViewCellDelegate: AnyObject { + func pressedButton() +} + +class ContactsTableViewCell: UITableViewCell { + + static let identifier = "ContactsTableViewCell" + + let expanded = false + let stackView = UIStackView() + let name = UILabel() + let moreStackView = UIStackView() + let call = UIButton() + let info = UIButton() + let paddingView = UIView() + let paddingView2 = UIView() + + var delegate: ContactsTableViewCellDelegate? + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + setUpView() + setUpValue() + setConstraints() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private func setUpView() { + paddingView.addSubview(name) + contentView.addSubview(stackView) + stackView.addArrangedSubview(paddingView) + stackView.addArrangedSubview(moreStackView) + moreStackView.addArrangedSubview(paddingView2) + moreStackView.addArrangedSubview(call) + } + + private func setUpValue() { + + paddingView.layoutMargins = UIEdgeInsets(top: 10, left: 30, bottom: 10, right: 30) + + name.text = "Name" + name.font = .preferredFont(forTextStyle: .title2) + + let imgConfig = UIImage.SymbolConfiguration(pointSize: 25) + call.setImage(UIImage(systemName: "phone.circle.fill", withConfiguration: imgConfig), for: .normal) + call.configuration = .plain() + call.configuration?.imagePadding = 10 + call.configuration?.baseForegroundColor = .systemGreen + call.addTarget(self, action: #selector(callBtnAction), for: .touchUpInside) + + stackView.axis = .vertical + stackView.alignment = .leading + stackView.distribution = .fillEqually +// stackView.layoutMargins = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10) +// stackView.isLayoutMarginsRelativeArrangement = true + + moreStackView.backgroundColor = .systemGray6 + moreStackView.axis = .horizontal + moreStackView.alignment = .fill + moreStackView.distribution = .fill + moreStackView.addBorders(edges: [.top], color: .systemGray4, thickness: 1) + moreStackView.layoutMargins = UIEdgeInsets(top: 0, left: 30, bottom: 0, right: 30) + moreStackView.isLayoutMarginsRelativeArrangement = true + } + + private func setConstraints() { + + paddingView.snp.makeConstraints { make in + make.top.equalTo(contentView.safeAreaLayoutGuide) + make.leading.equalTo(contentView.safeAreaLayoutGuide) + make.trailing.equalTo(contentView.safeAreaLayoutGuide) + } + name.snp.makeConstraints { make in + make.leading.equalTo(paddingView.layoutMarginsGuide) + make.top.equalTo(paddingView.layoutMarginsGuide) + make.bottom.equalTo(paddingView.layoutMarginsGuide) + } + stackView.snp.makeConstraints { make in + make.edges.equalTo(contentView.safeAreaLayoutGuide) + } + moreStackView.snp.makeConstraints { make in + make.leading.equalTo(contentView.safeAreaLayoutGuide) + make.trailing.equalTo(contentView.safeAreaLayoutGuide) + } + call.snp.makeConstraints { make in + make.leading.equalTo(contentView.snp.leading).offset(330) + } + } + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + moreStackView.isHidden = !selected + } + + @objc func callBtnAction(){ + delegate?.pressedButton() + } +} + +// MARK: - stackview border +extension UIStackView { + @discardableResult + func addBorders(edges: UIRectEdge, + color: UIColor, + inset: CGFloat = 0.0, + thickness: CGFloat = 1.0) -> [UIView] { + + var borders = [UIView]() + + @discardableResult + func addBorder(formats: String...) -> UIView { + let border = UIView(frame: .zero) + border.backgroundColor = color + border.translatesAutoresizingMaskIntoConstraints = false + addSubview(border) + addConstraints(formats.flatMap { + NSLayoutConstraint.constraints(withVisualFormat: $0, + options: [], + metrics: ["inset": inset, "thickness": thickness], + views: ["border": border]) }) + borders.append(border) + return border + } + + + if edges.contains(.top) || edges.contains(.all) { + addBorder(formats: "V:|-0-[border(==thickness)]", "H:|-inset-[border]-inset-|") + } + + if edges.contains(.bottom) || edges.contains(.all) { + addBorder(formats: "V:[border(==thickness)]-0-|", "H:|-inset-[border]-inset-|") + } + + if edges.contains(.left) || edges.contains(.all) { + addBorder(formats: "V:|-inset-[border]-inset-|", "H:|-0-[border(==thickness)]") + } + + if edges.contains(.right) || edges.contains(.all) { + addBorder(formats: "V:|-inset-[border]-inset-|", "H:[border(==thickness)]-0-|") + } + + return borders + } +} + + // MARK: - canvas 이용하기 +import SwiftUI +struct UIViewPreview: UIViewRepresentable { + let view: View + + init(_ builder: @escaping () -> View) { + view = builder() + } + + func makeUIView(context: Context) -> UIView { + return view + } + + func updateUIView(_ view: UIView, context: Context) { + view.setContentHuggingPriority(.defaultHigh, for: .horizontal) + view.setContentHuggingPriority(.defaultHigh, for: .vertical) + } +} + +struct ContactsTableViewCellPreview: PreviewProvider{ + static var previews: some View { + UIViewPreview { + let button = ContactsTableViewCell(frame: .zero) + return button + } + } +} diff --git a/iOS/Ringo/Ringo/FriendService.swift b/iOS/Ringo/Ringo/FriendService.swift new file mode 100644 index 00000000..13fd3ec6 --- /dev/null +++ b/iOS/Ringo/Ringo/FriendService.swift @@ -0,0 +1,66 @@ +// +// FriendService.swift +// Ringo +// +// Created by 강진혁 on 2/8/24. +// + +import Foundation +import Alamofire + +class FriendService { + + static let shared = FriendService() + + private init() {} + + func loadFriendsList(userId: Int64, completion: @escaping(NetworkResult) -> Void) + { +// let url = "http://192.168.0.7:7080/friendship/findByUserIdAndStatusOrFriendIdAndStatus" + let url = "https://4kringo.shop:8080/friendship/findByUserIdAndStatusOrFriendIdAndStatus" + + let header : HTTPHeaders = ["Content-Type" : "application/json"] + + let body : Parameters = [ + "userId" : userId + ] + + let dataRequest = AF.request(url, + method: .post, + parameters: body, + encoding: JSONEncoding.default, + headers: header) + + dataRequest.responseData{ + response in + switch response.result { + case .success: + guard let statusCode = response.response?.statusCode else {return} + guard let value = response.value else {return} + + let networkResult = self.judgeStatus(by: statusCode, value) + completion(networkResult) + + case .failure: + completion(.networkFail) + } + } + } + private func judgeStatus(by statusCode: Int, _ data: Data) -> NetworkResult { + switch statusCode { + case ..<300 : return isVaildData(data: data) + case 400..<500 : return .pathErr + case 500..<600 : return .serverErr + default : return .networkFail + } + } + //통신이 성공하고 원하는 데이터가 올바르게 들어왔을때 처리하는 함수 + private func isVaildData(data: Data) -> NetworkResult { + let decoder = JSONDecoder() //서버에서 준 데이터를 Codable을 채택, response가 json일 경우 + guard let decodedData = try? decoder.decode([String].self, from: data) + //데이터가 변환이 되게끔 Response 모델 구조체로 데이터를 변환해서 넣고, 그 데이터를 NetworkResult Success 파라미터로 전달 + else { return .pathErr } + + return .success(decodedData as Any) + } +} diff --git a/iOS/Ringo/Ringo/Info.plist b/iOS/Ringo/Ringo/Info.plist new file mode 100644 index 00000000..23be9eee --- /dev/null +++ b/iOS/Ringo/Ringo/Info.plist @@ -0,0 +1,27 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + UIBackgroundModes + + NSMicrophoneUsageDescription + Need Mic Access + + diff --git a/iOS/Ringo/Ringo/Model.swift b/iOS/Ringo/Ringo/Model.swift new file mode 100644 index 00000000..f9abc75a --- /dev/null +++ b/iOS/Ringo/Ringo/Model.swift @@ -0,0 +1,29 @@ +// +// Model.swift +// Ringo +// +// Created by 강진혁 on 2/6/24. +// + +import Foundation + +struct SigninData: Codable { + let id: Int + let eamil: String + let jwtToken: String + let refreshToken: String +} + +struct SigninDataResponse: Codable { + let data: SigninData? + let message: String + let result: String +} + +enum NetworkResult { + case success(T) + case requestErr(T) + case pathErr + case serverErr + case networkFail +} diff --git a/iOS/Ringo/Ringo/SceneDelegate.swift b/iOS/Ringo/Ringo/SceneDelegate.swift new file mode 100644 index 00000000..b081d288 --- /dev/null +++ b/iOS/Ringo/Ringo/SceneDelegate.swift @@ -0,0 +1,55 @@ +// +// SceneDelegate.swift +// Ringo +// +// Created by 강진혁 on 1/29/24. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + + guard let windowScene = (scene as? UIWindowScene) else { return } + window = UIWindow(windowScene: windowScene) + let mainViewController = ViewController() + + window?.rootViewController = mainViewController + window?.makeKeyAndVisible() + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/iOS/Ringo/Ringo/Screens/AccountViewController.swift b/iOS/Ringo/Ringo/Screens/AccountViewController.swift new file mode 100644 index 00000000..06d85d71 --- /dev/null +++ b/iOS/Ringo/Ringo/Screens/AccountViewController.swift @@ -0,0 +1,30 @@ +// +// AccountViewController.swift +// Ringo +// +// Created by 강진혁 on 2/1/24. +// + +import UIKit + +class AccountViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = .blue + // Do any additional setup after loading the view. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destination. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/iOS/Ringo/Ringo/Screens/ContactsViewController.swift b/iOS/Ringo/Ringo/Screens/ContactsViewController.swift new file mode 100644 index 00000000..a4df3d47 --- /dev/null +++ b/iOS/Ringo/Ringo/Screens/ContactsViewController.swift @@ -0,0 +1,161 @@ +// +// ContactsViewController.swift +// Ringo +// +// Created by 강진혁 on 2/1/24. +// + +import UIKit +import SnapKit + +class ContactsViewController: UIViewController { + + let contactsTableViewCell = ContactsTableViewCell.identifier + + var randomNames = [String]() + + let searchController = UISearchController() + var tableView: UITableView! + + override func viewDidLoad() { + super.viewDidLoad() + + //navigation + self.navigationItem.title = "Contacts" + self.navigationController?.navigationBar.prefersLargeTitles = true + self.navigationItem.searchController = searchController + self.navigationItem.hidesSearchBarWhenScrolling = false + self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(systemName: "person.badge.plus"), style: .plain, target: self, action: #selector(requestFriend)) + self.navigationItem.leftBarButtonItem = UIBarButtonItem(image: UIImage(systemName: "person"), style: .plain, target: self, action: #selector(test)) + + //table + tableView = UITableView() + tableView.register(ContactsTableViewCell.self, forCellReuseIdentifier: contactsTableViewCell) + tableView.delegate = self + tableView.dataSource = self + self.view.addSubview(tableView) + + setConstraints() + + loadFriends() + } + + func setConstraints(){ + tableView.snp.makeConstraints { make in + make.edges.equalTo(view.safeAreaLayoutGuide) + } + } + //navigaion rightBtn action + @objc private func requestFriend(_ sender: UIBarButtonItem) { + self.navigationController?.pushViewController(FriendRequestViewController(), animated: true) + } + + @objc private func test() { + DispatchQueue.global().async { + CallService.shared.signalClient.store(id: "rkdwltjr@naver.com") + } + } +} + +// MARK: - UITableViewDelegate + +extension ContactsViewController: UITableViewDelegate { + + func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { + let cell = tableView.cellForRow(at: indexPath) as! ContactsTableViewCell + if cell.isSelected == true { + cell.isSelected = false + cell.moreStackView.isHidden = true + tableView.beginUpdates() + tableView.setNeedsDisplay() + tableView.endUpdates() + return nil + } + return indexPath + } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + tableView.beginUpdates() + tableView.setNeedsDisplay() + tableView.endUpdates() + } + + func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) { + tableView.beginUpdates() + tableView.setNeedsDisplay() + tableView.endUpdates() + } + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + return UITableView.automaticDimension + } + +} +// MARK: - UITableViewDataSource + +extension ContactsViewController: UITableViewDataSource { + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return randomNames.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: contactsTableViewCell, for: indexPath) as! ContactsTableViewCell + + cell.name.text = randomNames[indexPath.row] + cell.selectionStyle = .none + cell.delegate = self + + return cell + } +} +// MARK: - Load Friends +extension ContactsViewController { + + func loadFriends() { + //id ??인 유저의 친구목록 + FriendService.shared.loadFriendsList(userId: 8) { response in + switch response { + case .success(let data): + + guard let data = data as? [String] else { return } + if !data.isEmpty { + self.randomNames = data + self.tableView.reloadData() + } else { + let alert = UIAlertController(title: "친구가 없습니다", message: "", preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "확인", style: .cancel, handler: nil)) + self.present(alert, animated: true, completion: nil) + } + + case .requestErr(let err): + print(err) + case .pathErr: + print("pathErr") + case .serverErr: + print("serverErr") + case .networkFail: + print("networkFail") + } + } + } +} + +// MARK: - Load Friends +extension ContactsViewController: ContactsTableViewCellDelegate { + + func pressedButton() { + CallService.shared.signalClient.startcall(id: "8", target: "10") + } + +} +// MARK: - canvas 이용하기 +import SwiftUI +@available(iOS 13.0.0, *) +struct ContactsViewControllerPreView: PreviewProvider { + static var previews: some View { + // 사용할 뷰 컨트롤러를 넣어주세요 + ContactsViewController() + .toPreview() + } +} diff --git a/iOS/Ringo/Ringo/Screens/FriendRequestViewController.swift b/iOS/Ringo/Ringo/Screens/FriendRequestViewController.swift new file mode 100644 index 00000000..7e387876 --- /dev/null +++ b/iOS/Ringo/Ringo/Screens/FriendRequestViewController.swift @@ -0,0 +1,33 @@ +// +// FriendRequestViewController.swift +// Ringo +// +// Created by 강진혁 on 2/2/24. +// + +import UIKit + +class FriendRequestViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = .brown + + self.navigationItem.title = "Request Friend" + self.navigationItem.largeTitleDisplayMode = .never + // Do any additional setup after loading the view. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destination. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/iOS/Ringo/Ringo/Screens/RecentsViewController.swift b/iOS/Ringo/Ringo/Screens/RecentsViewController.swift new file mode 100644 index 00000000..f0c94dea --- /dev/null +++ b/iOS/Ringo/Ringo/Screens/RecentsViewController.swift @@ -0,0 +1,30 @@ +// +// RecentsViewController.swift +// Ringo +// +// Created by 강진혁 on 2/1/24. +// + +import UIKit + +class RecentsViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + view.backgroundColor = .green + // Do any additional setup after loading the view. + } + + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + // Get the new view controller using segue.destination. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/iOS/Ringo/Ringo/Screens/TabBarViewController.swift b/iOS/Ringo/Ringo/Screens/TabBarViewController.swift new file mode 100644 index 00000000..8fb7ce26 --- /dev/null +++ b/iOS/Ringo/Ringo/Screens/TabBarViewController.swift @@ -0,0 +1,136 @@ +// +// TabBarViewController.swift +// Ringo +// +// Created by 강진혁 on 2/1/24. +// + +import UIKit +import SnapKit +import WebRTC + +class TabBarViewController: UITabBarController{ + + override func viewDidLoad() { + super.viewDidLoad() + + CallService.shared.webRTCClient.delegate = self + CallService.shared.signalClient.delegate = self + CallService.shared.signalClient.connect() + + view.backgroundColor = .systemBackground + + tabBar.backgroundColor = .systemGray6 + + let contactsVC = UINavigationController(rootViewController: ContactsViewController()) + let recentsVC = RecentsViewController() + let accountVC = AccountViewController() + + contactsVC.tabBarItem = UITabBarItem(title: "Contacts", image: UIImage(systemName: "person.3"), tag: 1) + recentsVC.tabBarItem = UITabBarItem(title: "Recents", image: UIImage(systemName: "clock"), tag: 2) + accountVC.tabBarItem = UITabBarItem(title: "Account", image: UIImage(systemName: "person.text.rectangle"), tag: 3) + + contactsVC.navigationBar.backgroundColor = .systemBackground + + setViewControllers([contactsVC,recentsVC,accountVC], animated: false) + } +} + +extension TabBarViewController: SignalClientDelegate { + func signalClientDidConnect(_ signalClient: SignalingClient) { + print("signal connect") + } + + func signalClientDidDisconnect(_ signalClient: SignalingClient) { + print("signal disconnect") + } + + func signalClient(_ signalClient: SignalingClient, didReceiveRemoteSdp sdp: RTCSessionDescription) { + print("Received remote sdp") + CallService.shared.webRTCClient.set(remoteSdp: sdp) { (error) in + DispatchQueue.main.async { + let alert = UIAlertController(title: "Call", message: "", preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "Refuse", style: .destructive, handler: nil)) + alert.addAction(UIAlertAction(title: "Accept", style: .default, handler: { action in + self.acceptCall() + })) + self.present(alert, animated: true, completion: nil) + } + } + } + + func signalClient(_ signalClient: SignalingClient, didReceiveCandidate candidate: RTCIceCandidate) { + CallService.shared.webRTCClient.set(remoteCandidate: candidate) { error in + print("Received remote candidate : \(candidate)") + } + } + + func signalClient(_ signalClient: SignalingClient, didReceiveCallResponse response: String) { + if response == "user is ready for call" { + CallService.shared.webRTCClient.offer { (sdp) in + var message = Message(type: .create_offer, name: "rkdwltjr@naver.com", target: "rkdwlsgur@naver.com") + message.data = .sdp(SessionDescription(from: sdp)) + CallService.shared.signalClient.send(message: message) + } + DispatchQueue.main.async { [self] in + let connectionVC = ConnectionViewController() + connectionVC.modalPresentationStyle = .fullScreen + present(connectionVC, animated: true,completion: nil) + } + } else { + debugPrint("response message") + debugPrint(response) + } + } + + func signalClient(_ signalClient: SignalingClient, didReceiveTranslation msg: String, language: String) { + TTS.shared.play(msg, language) + } + + func acceptCall() { + CallService.shared.webRTCClient.answer { (localSdp) in + var message = Message(type: .create_answer, name: "rkdwltjr@naver.com", target: "rkdwlsgur@naver.com") + message.data = .sdp(SessionDescription(from: localSdp)) + CallService.shared.signalClient.send(message: message) +// CallService.shared.signalClient.send(sdp: localSdp) + } + let connectionVC = ConnectionViewController() + connectionVC.modalPresentationStyle = .fullScreen + self.present(connectionVC, animated: true,completion: nil) + } + +} + +extension TabBarViewController: WebRTCClientDelegate { + func webRTCClient(_ client: WebRTCClient, didDiscoverLocalCandidate candidate: RTCIceCandidate) { + print("discovered local candidate") + var message = Message(type: .ice_candidate, name: "rkdwltjr@naver.com", target: "rkdwlsgur@naver.com") + message.data = .candidate(IceCandidate(from: candidate)) + CallService.shared.signalClient.send(message: message) +// CallService.shared.signalClient.send(candidate: candidate) + } + + func webRTCClient(_ client: WebRTCClient, didChangeConnectionState state: RTCIceConnectionState) { + print("change connection state : \(state)") + } + + func webRTCClient(_ client: WebRTCClient, didReceiveData data: Data) { + DispatchQueue.main.async { + let message = String(data: data, encoding: .utf8) ?? "(Binary: \(data.count) bytes)" + let alert = UIAlertController(title: "Message from WebRTC", message: message, preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil)) + self.present(alert, animated: true, completion: nil) + } + } +} + +// MARK: canvas 이용하기 +import SwiftUI +@available(iOS 13.0.0, *) +struct TabBarViewControllerPreView: PreviewProvider { + static var previews: some View { + // 사용할 뷰 컨트롤러를 넣어주세요 + TabBarViewController() + .toPreview() + } +} diff --git a/iOS/Ringo/Ringo/Screens/ViewController.swift b/iOS/Ringo/Ringo/Screens/ViewController.swift new file mode 100644 index 00000000..f8d15ff1 --- /dev/null +++ b/iOS/Ringo/Ringo/Screens/ViewController.swift @@ -0,0 +1,318 @@ +// +// ViewController.swift +// Ringo +// +// Created by 강진혁 on 1/29/24. +// + +import UIKit +import SnapKit + +class ViewController: UIViewController { + + let Text1 = UILabel() + let Text2 = UILabel() + let Text3 = UILabel() + let signupBtn = UIButton() + let email = UILabel() + let input_email = UITextField() + let passwd = UILabel() + let input_passwd = UITextField() + var showBtn = UIButton() + let forgotPwBtn = UIButton() + let signinBtn = UIButton() + let Text4 = UILabel() + let google = UIButton() + let apple = UIButton() + let facebook = UIButton() + let error = UIButton(type: .custom) + let stackView = UIStackView() + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + setUpValue() + setUpView() + setConstraints() + } + + func setUpView() { + view.addSubview(Text1) + view.addSubview(Text2) + view.addSubview(Text3) + view.addSubview(signupBtn) + view.addSubview(email) + view.addSubview(input_email) + view.addSubview(forgotPwBtn) + view.addSubview(signinBtn) + view.addSubview(Text4) + view.addSubview(google) + view.addSubview(apple) + view.addSubview(facebook) + + view.addSubview(stackView) + stackView.addArrangedSubview(passwd) + stackView.addArrangedSubview(input_passwd) + stackView.addArrangedSubview(error) + } + + func setUpValue() { + view.backgroundColor = .systemBackground + let button_plain = UIButton.Configuration.plain() + let button_filled = UIButton.Configuration.filled() + + Text1.text = "Sign in" + Text1.font = .preferredFont(forTextStyle: .title1) + + Text2.text = "If you don't have an account register \nYou can" + Text2.font = .preferredFont(forTextStyle: .body) + + Text3.text = "You can" + Text3.font = .preferredFont(forTextStyle: .body) + + signupBtn.setTitle("Sign up here!", for: .normal) + signupBtn.setTitleColor(.systemBlue, for: .normal) + signupBtn.titleLabel?.font = .systemFont(ofSize: 18) + signupBtn.setTitleColor(.systemBlue.withAlphaComponent(0.5), for: .highlighted) + + email.text = "E-mail" + email.font = .preferredFont(forTextStyle: .body) + + input_email.placeholder = "Enter your email" + input_email.borderStyle = .roundedRect + input_email.layer.borderWidth = 1.5 + input_email.layer.borderColor = UIColor(hexCode: "E2E8F0").cgColor + input_email.layer.cornerRadius = 5 + input_email.keyboardType = .emailAddress + input_email.autocapitalizationType = .none + input_email.autocorrectionType = .no + input_email.spellCheckingType = .no + + stackView.axis = .vertical + stackView.alignment = .fill + stackView.distribution = .equalSpacing + stackView.spacing = 10 + + passwd.text = "Password" + passwd.font = .preferredFont(forTextStyle: .body) + + showBtn = UIButton.init(primaryAction: UIAction(handler: { _ in + self.input_passwd.isSecureTextEntry.toggle() + self.showBtn.isSelected.toggle() + })) + + showBtn.configuration = button_plain + showBtn.configuration?.baseBackgroundColor = .clear + showBtn.configurationUpdateHandler = { btn in + switch btn.state { + case .selected: + btn.configuration?.image = UIImage(systemName: "eye") + default: + btn.configuration?.image = UIImage(systemName: "eye.slash") + } + } + + input_passwd.placeholder = "Enter your password" + input_passwd.borderStyle = .roundedRect + input_passwd.isSecureTextEntry = true + input_passwd.rightView = showBtn + input_passwd.rightViewMode = .always + input_passwd.autocapitalizationType = .none + input_passwd.delegate = self + input_passwd.autocorrectionType = .no + input_passwd.spellCheckingType = .no + + error.layer.isHidden = true + error.setTitle(" Incorrect password. Please check your password.", for: .normal) + error.setTitleColor(.red, for: .normal) + error.titleLabel?.font = .systemFont(ofSize: 13) + error.setImage(UIImage(systemName: "info.circle"), for: .normal) + error.setImage(UIImage(systemName: "info.circle"), for: .highlighted) + error.tintColor = .red + + forgotPwBtn.setTitle("Forgot Password?", for: .normal) + forgotPwBtn.setTitleColor(.systemBlue, for: .normal) + forgotPwBtn.titleLabel?.font = .systemFont(ofSize: 13) + forgotPwBtn.setTitleColor(.systemBlue.withAlphaComponent(0.5), for: .highlighted) + + signinBtn.configuration = button_filled + signinBtn.configuration?.buttonSize = .large + signinBtn.setTitle("Sign in", for: .normal) + signinBtn.layer.shadowColor = UIColor.systemBlue.cgColor + signinBtn.layer.shadowRadius = 15 + signinBtn.layer.shadowOpacity = 0.5 + signinBtn.layer.shadowOffset = CGSize(width: 0, height: 0) + signinBtn.layer.masksToBounds = false + signinBtn.addTarget(self, action: #selector(onPressSignin(_:)), for: .touchUpInside) +// signinBtn.addAction(UIAction{_ in self.login()}, for: .touchUpInside) + + Text4.text = "or continue with" + Text4.font = .preferredFont(forTextStyle: .body) + Text4.textColor = .lightGray + + google.setImage(UIImage(named: "Google"), for: .normal) + apple.setImage(UIImage(named: "Apple"), for: .normal) + facebook.setImage(UIImage(named: "Facebook"), for: .normal) + } + + func setConstraints(){ + Text1.snp.makeConstraints { make in + make.top.equalTo(view.safeAreaLayoutGuide).offset(30) + make.leading.equalToSuperview().offset(30) + } + + Text2.snp.makeConstraints { make in + make.top.equalTo(Text1.snp.bottom).offset(20) + make.leading.equalTo(Text1.snp.leading) + } + + Text3.snp.makeConstraints { make in + make.top.equalTo(Text2.snp.bottom).offset(10) + make.leading.equalTo(Text2.snp.leading) + } + + signupBtn.snp.makeConstraints { make in + make.top.equalTo(Text2.snp.top).offset(24) + make.leading.equalTo(Text2.snp.leading).offset(70) + } + + email.snp.makeConstraints { make in + make.top.equalTo(Text2.snp.bottom).offset(100) + make.leading.equalToSuperview().offset(20) + } + + input_email.snp.makeConstraints { make in + make.top.equalTo(email.snp.bottom).offset(10) + make.leading.equalTo(email.snp.leading) + make.trailing.equalToSuperview().offset(-20) + } + + stackView.snp.makeConstraints { make in + make.top.equalTo(input_email.snp.bottom).offset(20) + make.leading.equalTo(email.snp.leading) + make.trailing.equalTo(input_email.snp.trailing) + } + + forgotPwBtn.snp.makeConstraints { make in + make.top.equalTo(stackView.snp.bottom).offset(10) + make.trailing.equalTo(stackView.snp.trailing) + } + + signinBtn.snp.makeConstraints { make in + make.top.equalTo(input_passwd.snp.bottom).offset(90) + make.leading.equalTo(stackView.snp.leading) + make.trailing.equalTo(stackView.snp.trailing) + } + + Text4.snp.makeConstraints { make in + make.bottom.equalTo(view.safeAreaLayoutGuide).offset(-110) + make.centerX.equalToSuperview() + } + + google.snp.makeConstraints { make in + make.top.equalTo(Text4.snp.bottom).offset(20) + make.leading.equalTo(apple.snp.trailing).offset(20) + } + + apple.snp.makeConstraints { make in + make.top.equalTo(Text4.snp.bottom).offset(20) + make.centerX.equalToSuperview() + } + + facebook.snp.makeConstraints { make in + make.top.equalTo(Text4.snp.bottom).offset(20) + make.trailing.equalTo(apple.snp.leading).offset(-20) + } + } + // 빈 화면 터치 시 키보드 내리기 + override func touchesBegan(_ touches: Set, with event: UIEvent?) { + view.endEditing(true) + } + + @objc func onPressSignin(_ sender: UIButton) { + login() + } +} + +// MARK: - canvas 이용하기 +import SwiftUI +@available(iOS 13.0.0, *) +struct ViewPreview: PreviewProvider { + static var previews: some View { + ViewController().toPreview() + } +} +// MARK: - hexcode로 색 지정하기 +extension UIColor { + + convenience init(hexCode: String, alpha: CGFloat = 1.0) { + var hexFormatted: String = hexCode.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).uppercased() + + if hexFormatted.hasPrefix("#") { + hexFormatted = String(hexFormatted.dropFirst()) + } + + assert(hexFormatted.count == 6, "Invalid hex code used.") + + var rgbValue: UInt64 = 0 + Scanner(string: hexFormatted).scanHexInt64(&rgbValue) + + self.init(red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0, + green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0, + blue: CGFloat(rgbValue & 0x0000FF) / 255.0, + alpha: alpha) + } +} +// MARK: - Sign in +extension ViewController { + + func login() { + + guard let email = input_email.text else { return } + guard let passward = input_passwd.text else { return } + + SigninSercive.shared.login(email: email, password: passward) { response in + switch response { + case .success(let data): + + guard let data = data as? String else { return } + if data == "success"{ +// UserDefaults.standard.set(data.data?.jwtToken, forKey: "jwtToken") + let nav = UINavigationController() + nav.modalPresentationStyle = .fullScreen + + //네비게이션 중복 수정 1/31 + nav.navigationBar.isHidden = true + + let controller = TabBarViewController() + nav.viewControllers = [controller] + self.present(nav, animated: true, completion: nil) + } else { + let alert = UIAlertController(title: data, message: "", preferredStyle: .alert) + alert.addAction(UIAlertAction(title: "확인", style: .cancel, handler: nil)) + // alert.addAction(UIAlertAction(title: "DEFAULT", style: .default, handler: nil)) + // alert.addAction(UIAlertAction(title: "DESTRUCTIVE", style: .destructive, handler: nil)) + + self.present(alert, animated: true, completion: nil) + print(data) + } + + case .requestErr(let err): + print(err) + case .pathErr: + print("pathErr") + case .serverErr: + print("serverErr") + case .networkFail: + print("networkFail") + } + } + } +} +// MARK: +extension ViewController: UITextFieldDelegate { + func textFieldShouldReturn(_ textField: UITextField) -> Bool { + textField.resignFirstResponder() + return true + } +} diff --git a/iOS/Ringo/Ringo/SigninService.swift b/iOS/Ringo/Ringo/SigninService.swift new file mode 100644 index 00000000..f7a8baa4 --- /dev/null +++ b/iOS/Ringo/Ringo/SigninService.swift @@ -0,0 +1,76 @@ +// +// SigninService.swift +// Ringo +// +// Created by 강진혁 on 2/6/24. +// + +import Foundation +import Alamofire +//(1) 라이브러리 추가 + +class SigninSercive { + + static let shared = SigninSercive() +//(2)싱글통 객체를 선언해서 앱 어디에서든지 접근가능하도록 한다 + private init() {} + + func login(email: String, password: String, completion: @escaping(NetworkResult) -> Void) + { +// let url = "http://192.168.0.7:7080/member/login" //통신할 API 주소 + let url = "https://4kringo.shop:8080/member/login" //통신할 API 주소 + + //HTTP Headers : 요청 헤더 + let header : HTTPHeaders = ["Content-Type" : "application/json"] + + //요청 바디 + let body : Parameters = [ + "loginEmail" : email, + "password" : password + ] + + //요청서 //Request 생성 + //통신할 주소, HTTP메소드, 요청방식, 인코딩방식, 요청헤더 + let dataRequest = AF.request(url, + method: .post, + parameters: body, + encoding: JSONEncoding.default, + headers: header) + + //request 시작 ,responseData를 호출하면서 데이터 통신 시작 + dataRequest.responseData{ + response in //데이터 통신의 결과가 response에 담기게 된다 + switch response.result { + case .success: //데이터 통신이 성공한 경우에 + guard let statusCode = response.response?.statusCode else {return} + guard let value = response.value else {return} + + let networkResult = self.judgeStatus(by: statusCode, value) + completion(networkResult) + + + case .failure: + completion(.networkFail) + } + } + } + private func judgeStatus(by statusCode: Int, _ data: Data) -> NetworkResult { + switch statusCode { + case ..<300 : return isVaildData(data: data) + case 400..<500 : return .pathErr + case 500..<600 : return .serverErr + default : return .networkFail + } + } + //통신이 성공하고 원하는 데이터가 올바르게 들어왔을때 처리하는 함수 + private func isVaildData(data: Data) -> NetworkResult { + // response가 string일 경우 + let decodedata = String(data: data, encoding: .utf8) +// let decoder = JSONDecoder() //서버에서 준 데이터를 Codable을 채택, response가 json일 경우 + guard let decodedData = /*try? decoder.decode(SigninDataResponse.self, from: data)*/ decodedata + //데이터가 변환이 되게끔 Response 모델 구조체로 데이터를 변환해서 넣고, 그 데이터를 NetworkResult Success 파라미터로 전달 + else { return .pathErr } + + return .success(decodedData as Any) + } +} diff --git a/iOS/Ringo/Ringo/TTS.swift b/iOS/Ringo/Ringo/TTS.swift new file mode 100644 index 00000000..b76ea031 --- /dev/null +++ b/iOS/Ringo/Ringo/TTS.swift @@ -0,0 +1,29 @@ +// +// TTS.swift +// Ringo +// +// Created by 강진혁 on 3/20/24. +// + +import Foundation +import AVFoundation + +class TTS { + static let shared = TTS() + + private var synthesizer = AVSpeechSynthesizer() + + func play(_ string: String, _ language: String) { + debugPrint("문장 : " + string) + let utterance = AVSpeechUtterance(string: string) + utterance.voice = AVSpeechSynthesisVoice(language: language) + utterance.rate = 0.4 + synthesizer.stopSpeaking(at: .immediate) + synthesizer.speak(utterance) + } + + func stop() { + synthesizer.stopSpeaking(at: .immediate) + } + +} diff --git a/iOS/Ringo/Ringo/TestSTTViewController.swift b/iOS/Ringo/Ringo/TestSTTViewController.swift new file mode 100644 index 00000000..5f158b2d --- /dev/null +++ b/iOS/Ringo/Ringo/TestSTTViewController.swift @@ -0,0 +1,205 @@ +// +// TestSTTViewController.swift +// Ringo +// +// Created by 강진혁 on 2/21/24. +// + +import UIKit +import SnapKit +import Speech + +class TestSTTViewController: UIViewController, SFSpeechRecognizerDelegate { + + private let speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "ko-KR"))! + + private var recognitionRequest: SFSpeechAudioBufferRecognitionRequest? + + private var recognitionTask: SFSpeechRecognitionTask? + + private let audioEngine = AVAudioEngine() + + var textView = UITextView() + + var recordButton = UIButton() + + override func viewDidLoad() { + super.viewDidLoad() + + setUpView() + setUpValue() + setConstraints() + } + + func setUpView() { + view.addSubview(textView) + view.addSubview(recordButton) + } + + func setUpValue() { + + view.backgroundColor = .systemBackground + + textView.font = .systemFont(ofSize: 30) + + recordButton.configuration = .plain() + recordButton.isEnabled = false + recordButton.addTarget(self, action: #selector(recordButtonTapped), for: .touchUpInside) + recordButton.setTitle("말하기", for: .disabled) + recordButton.titleLabel?.font = .systemFont(ofSize: 50) + } + + func setConstraints() { + textView.snp.makeConstraints { make in + make.top.equalTo(view.safeAreaLayoutGuide) + make.leading.equalTo(view.safeAreaLayoutGuide) + make.trailing.equalTo(view.safeAreaLayoutGuide) + make.bottom.equalTo(recordButton.snp.top) + } + recordButton.snp.makeConstraints { make in + make.bottom.equalTo(view.safeAreaLayoutGuide).inset(30) + make.centerX.equalTo(view.center.x) + } + } + + override public func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + // Configure the SFSpeechRecognizer object already + // stored in a local member variable. + speechRecognizer.delegate = self + + // Make the authorization request. + SFSpeechRecognizer.requestAuthorization { authStatus in + + // Divert to the app's main thread so that the UI + // can be updated. + OperationQueue.main.addOperation { + switch authStatus { + case .authorized: + self.recordButton.isEnabled = true + case .denied: + self.recordButton.isEnabled = false + self.recordButton.setTitle("User denied access to speech recognition", for: .disabled) + + case .restricted: + self.recordButton.isEnabled = false + self.recordButton.setTitle("Speech recognition restricted on this device", for: .disabled) + + case .notDetermined: + self.recordButton.isEnabled = false + self.recordButton.setTitle("Speech recognition not yet authorized", for: .disabled) + + default: + self.recordButton.isEnabled = false + } + } + } + } + + private func startRecording() throws { + + // Cancel the previous task if it's running. + if let recognitionTask = recognitionTask { + recognitionTask.cancel() + self.recognitionTask = nil + } + + // Configure the audio session for the app. + let audioSession = AVAudioSession.sharedInstance() + try audioSession.setCategory(.playAndRecord, mode: .measurement, options: .mixWithOthers) + try audioSession.setActive(true, options: .notifyOthersOnDeactivation) + let inputNode = audioEngine.inputNode + + // Create and configure the speech recognition request. + recognitionRequest = SFSpeechAudioBufferRecognitionRequest() + guard let recognitionRequest = recognitionRequest else { fatalError("Unable to created a SFSpeechAudioBufferRecognitionRequest object") } + recognitionRequest.shouldReportPartialResults = true + + // Keep speech recognition data on device + if #available(iOS 13, *) { + recognitionRequest.requiresOnDeviceRecognition = true + } + + // Create a recognition task for the speech recognition session. + // Keep a reference to the task so that it can be canceled. + recognitionTask = speechRecognizer.recognitionTask(with: recognitionRequest) { result, error in + var isFinal = false + + if let result = result { + // Update the text view with the results. + self.textView.text = result.bestTranscription.formattedString + isFinal = result.isFinal + debugPrint(result.bestTranscription.formattedString) + if result.speechRecognitionMetadata != nil { + var message = Message(type: .stt_message, name: "rkdwlsgur@naver.com", target: "rkdwltjr@naver.com") + message.data = .response(result.bestTranscription.formattedString) + CallService.shared.signalClient.send(message: message) + debugPrint("send trans msg") + } + } + + if error != nil || isFinal { + // Stop recognizing speech if there is a problem. + self.audioEngine.stop() + inputNode.removeTap(onBus: 0) + + self.recognitionRequest = nil + self.recognitionTask = nil + + self.recordButton.isEnabled = true + self.recordButton.setTitle("말하기", for: []) + } + } + + // Configure the microphone input. + let recordingFormat = inputNode.outputFormat(forBus: 0) + inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) { (buffer: AVAudioPCMBuffer, when: AVAudioTime) in + self.recognitionRequest?.append(buffer) + } + + audioEngine.prepare() + try audioEngine.start() + + // Let the user know to start talking. + textView.text = "(말해보세요)" + } + + // MARK: SFSpeechRecognizerDelegate + + public func speechRecognizer(_ speechRecognizer: SFSpeechRecognizer, availabilityDidChange available: Bool) { + if available { + recordButton.isEnabled = true + recordButton.setTitle("말하기", for: []) + } else { + recordButton.isEnabled = false + recordButton.setTitle("Recognition Not Available", for: .disabled) + } + } + + // MARK: Interface Builder actions + + @objc func recordButtonTapped() { + if audioEngine.isRunning { + audioEngine.stop() + recognitionRequest?.endAudio() + recordButton.isEnabled = false + recordButton.setTitle("Stopping", for: .disabled) + } else { + do { + try startRecording() + recordButton.setTitle("그만 말하기", for: []) + } catch { + recordButton.setTitle("Recording Not Available", for: []) + } + } + } + +} +// MARK: - canvas 이용하기 +import SwiftUI +@available(iOS 13.0.0, *) +struct TestSTTViewPreview: PreviewProvider { + static var previews: some View { + TestSTTViewController().toPreview() + } +} diff --git a/iOS/Ringo/Ringo/WebRTC/.DS_Store b/iOS/Ringo/Ringo/WebRTC/.DS_Store new file mode 100644 index 00000000..9c56828c Binary files /dev/null and b/iOS/Ringo/Ringo/WebRTC/.DS_Store differ diff --git a/iOS/Ringo/Ringo/WebRTC/CallService.swift b/iOS/Ringo/Ringo/WebRTC/CallService.swift new file mode 100644 index 00000000..2934a7af --- /dev/null +++ b/iOS/Ringo/Ringo/WebRTC/CallService.swift @@ -0,0 +1,22 @@ +// +// CallService.swift +// Ringo +// +// Created by 강진혁 on 2/13/24. +// + +import Foundation + +class CallService { + + static let shared = CallService() + + private let config = Config.default + var signalClient: SignalingClient + var webRTCClient: WebRTCClient + + init() { + self.signalClient = SignalingClient(webSocket: NativeWebSocket(url: self.config.signalingServerUrl)) + self.webRTCClient = WebRTCClient(iceServers: self.config.webRTCIceServers) + } +} diff --git a/iOS/Ringo/Ringo/WebRTC/Config.swift b/iOS/Ringo/Ringo/WebRTC/Config.swift new file mode 100644 index 00000000..de4ba4cb --- /dev/null +++ b/iOS/Ringo/Ringo/WebRTC/Config.swift @@ -0,0 +1,37 @@ +// +// Config.swift +// WebRTC-Demo +// +// Created by Stasel on 30/01/2019. +// Copyright © 2019 Stasel. All rights reserved. +// + +import Foundation +import WebRTC + +// Set this to the machine's address which runs the signaling server. Do not use 'localhost' or '127.0.0.1' +//fileprivate let defaultSignalingServerUrl = URL(string: "ws://localhost:8080/signal")! +//fileprivate let defaultSignalingServerUrl = URL(string: "ws://192.168.0.7:7080/signal")! +fileprivate let defaultSignalingServerUrl = URL(string: "wss://4kringo.shop:8080/signal")! + +// We use Google's public stun servers. For production apps you should deploy your own stun/turn servers. +fileprivate let stunServers = ["stun:stun.l.google.com:19302", + "stun:stun1.l.google.com:19302", + "stun:stun2.l.google.com:19302", + "stun:stun3.l.google.com:19302", + "stun:stun4.l.google.com:19302"] + +fileprivate let defaultStunServers = RTCIceServer(urlStrings: stunServers) + +fileprivate let defaultTurnServers = [ + RTCIceServer(urlStrings: ["turn:13.125.213.128"], username: "ringo", credential: "qaz7410") +] + +fileprivate let defaultIceServers = [defaultStunServers] + defaultTurnServers + +struct Config { + let signalingServerUrl: URL + let webRTCIceServers: [RTCIceServer] + + static let `default` = Config(signalingServerUrl: defaultSignalingServerUrl, webRTCIceServers: defaultIceServers) +} diff --git a/iOS/Ringo/Ringo/WebRTC/Extensions/IceCandidate.swift b/iOS/Ringo/Ringo/WebRTC/Extensions/IceCandidate.swift new file mode 100644 index 00000000..7959de1a --- /dev/null +++ b/iOS/Ringo/Ringo/WebRTC/Extensions/IceCandidate.swift @@ -0,0 +1,27 @@ +// +// IceCandidate.swift +// WebRTC-Demo +// +// Created by Stasel on 20/02/2019. +// Copyright © 2019 Stasel. All rights reserved. +// + +import Foundation +import WebRTC + +/// This struct is a swift wrapper over `RTCIceCandidate` for easy encode and decode +struct IceCandidate: Codable { + let sdpCandidate: String + let sdpMLineIndex: Int32 + let sdpMid: String? + + init(from iceCandidate: RTCIceCandidate) { + self.sdpMLineIndex = iceCandidate.sdpMLineIndex + self.sdpMid = iceCandidate.sdpMid + self.sdpCandidate = iceCandidate.sdp + } + + var rtcIceCandidate: RTCIceCandidate { + return RTCIceCandidate(sdp: self.sdpCandidate, sdpMLineIndex: self.sdpMLineIndex, sdpMid: self.sdpMid) + } +} diff --git a/iOS/Ringo/Ringo/WebRTC/Extensions/RTCStates.swift b/iOS/Ringo/Ringo/WebRTC/Extensions/RTCStates.swift new file mode 100644 index 00000000..9c5302f2 --- /dev/null +++ b/iOS/Ringo/Ringo/WebRTC/Extensions/RTCStates.swift @@ -0,0 +1,64 @@ +// +// RTCConnectionState.swift +// WebRTC +// +// Created by Stasel on 20/05/2018. +// Copyright © 2018 Stasel. All rights reserved. +// + +import Foundation +import WebRTC + +extension RTCIceConnectionState: CustomStringConvertible { + public var description: String { + switch self { + case .new: return "new" + case .checking: return "checking" + case .connected: return "connected" + case .completed: return "completed" + case .failed: return "failed" + case .disconnected: return "disconnected" + case .closed: return "closed" + case .count: return "count" + @unknown default: return "Unknown \(self.rawValue)" + } + } +} + +extension RTCSignalingState: CustomStringConvertible { + public var description: String { + switch self { + case .stable: return "stable" + case .haveLocalOffer: return "haveLocalOffer" + case .haveLocalPrAnswer: return "haveLocalPrAnswer" + case .haveRemoteOffer: return "haveRemoteOffer" + case .haveRemotePrAnswer: return "haveRemotePrAnswer" + case .closed: return "closed" + @unknown default: return "Unknown \(self.rawValue)" + } + } +} + +extension RTCIceGatheringState: CustomStringConvertible { + public var description: String { + switch self { + case .new: return "new" + case .gathering: return "gathering" + case .complete: return "complete" + @unknown default: return "Unknown \(self.rawValue)" + } + } +} + +extension RTCDataChannelState: CustomStringConvertible { + public var description: String { + switch self { + case .connecting: return "connecting" + case .open: return "open" + case .closing: return "closing" + case .closed: return "closed" + @unknown default: return "Unknown \(self.rawValue)" + } + } +} + diff --git a/iOS/Ringo/Ringo/WebRTC/Extensions/SessionDescription.swift b/iOS/Ringo/Ringo/WebRTC/Extensions/SessionDescription.swift new file mode 100644 index 00000000..e010fa67 --- /dev/null +++ b/iOS/Ringo/Ringo/WebRTC/Extensions/SessionDescription.swift @@ -0,0 +1,47 @@ +// +// SessionDescription.swift +// WebRTC-Demo +// +// Created by Stasel on 20/02/2019. +// Copyright © 2019 Stasel. All rights reserved. +// + +import Foundation +import WebRTC + +/// This enum is a swift wrapper over `RTCSdpType` for easy encode and decode +enum SdpType: String, Codable { + case OFFER, prAnswer, ANSWER, rollback + + var rtcSdpType: RTCSdpType { + switch self { + case .OFFER: return .offer + case .ANSWER: return .answer + case .prAnswer: return .prAnswer + case .rollback: return .rollback + } + } +} + +/// This struct is a swift wrapper over `RTCSessionDescription` for easy encode and decode +struct SessionDescription: Codable { + let sdp: String + let type: SdpType + + init(from rtcSessionDescription: RTCSessionDescription) { + self.sdp = rtcSessionDescription.sdp + + switch rtcSessionDescription.type { + case .offer: self.type = .OFFER + case .prAnswer: self.type = .prAnswer + case .answer: self.type = .ANSWER + case .rollback: self.type = .rollback + @unknown default: + fatalError("Unknown RTCSessionDescription type: \(rtcSessionDescription.type.rawValue)") + } + } + + var rtcSessionDescription: RTCSessionDescription { + return RTCSessionDescription(type: self.type.rtcSdpType, sdp: self.sdp) + } +} diff --git a/iOS/Ringo/Ringo/WebRTC/Services/Message.swift b/iOS/Ringo/Ringo/WebRTC/Services/Message.swift new file mode 100644 index 00000000..12e0a448 --- /dev/null +++ b/iOS/Ringo/Ringo/WebRTC/Services/Message.swift @@ -0,0 +1,135 @@ +// +// Message.swift +// WebRTC-Demo +// +// Created by Stasel on 20/02/2019. +// Copyright © 2019 Stasel. All rights reserved. +// + +import Foundation + +//enum Message { +// case sdp(SessionDescription) +// case candidate(IceCandidate) +//} +// +//extension Message: Codable { +// init(from decoder: Decoder) throws { +// let container = try decoder.container(keyedBy: CodingKeys.self) +// let type = try container.decode(String.self, forKey: .type) +// switch type { +// case String(describing: SessionDescription.self): +// self = .sdp(try container.decode(SessionDescription.self, forKey: .payload)) +// case String(describing: IceCandidate.self): +// self = .candidate(try container.decode(IceCandidate.self, forKey: .payload)) +// default: +// throw DecodeError.unknownType +// } +// } +// +// func encode(to encoder: Encoder) throws { +// var container = encoder.container(keyedBy: CodingKeys.self) +// switch self { +// case .sdp(let sessionDescription): +// try container.encode(sessionDescription, forKey: .payload) +// try container.encode(String(describing: SessionDescription.self), forKey: .type) +// case .candidate(let iceCandidate): +// try container.encode(iceCandidate, forKey: .payload) +// try container.encode(String(describing: IceCandidate.self), forKey: .type) +// } +// } +// +// enum DecodeError: Error { +// case unknownType +// } +// +// enum CodingKeys: String, CodingKey { +// case type, payload +// } +//} + + + +struct Message: Codable { + + enum MessageType: String, Codable { + case call_response, create_offer, offer_received, create_answer, answer_received, ice_candidate, start_call, stt_message, translate_message + } + + enum DataType { + case sdp(SessionDescription) + case candidate(IceCandidate) + case response(String) + + func stringValue() -> String { + switch self { + case .sdp(let sessionDescription): + return sessionDescription.sdp + case .candidate(let iceCandidate): + return iceCandidate.sdpCandidate + case .response(let string): + return string + } + } + } + + var type: MessageType + var name: String? + var target: String? + var data: DataType = .response("") + + init(type: MessageType, name: String, target: String){ + self.type = type + self.name = name + self.target = target + } + + init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.type = try container.decode(MessageType.self, forKey: .type) + self.name = try? container.decode(String.self, forKey: .name) + self.target = try? container.decode(String.self, forKey: .target) + switch type { + case .call_response,.stt_message,.translate_message: + self.data = .response(try container.decode(String.self, forKey: .data)) + case .create_offer,.offer_received,.create_answer,.answer_received: + debugPrint("sdp") + self.data = .sdp(try container.decode(SessionDescription.self, forKey: .data)) + case .ice_candidate: + debugPrint("ice") + self.data = .candidate(try container.decode(IceCandidate.self, forKey: .data)) + case .start_call: + debugPrint("startcall") + } + } + + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(type, forKey: .type) + try container.encode(name, forKey: .name) + try container.encode(target, forKey: .target) + switch data { + case .sdp(let sessionDescription): + try container.encode(sessionDescription, forKey: .data) + case .candidate(let iceCandidate): + try container.encode(iceCandidate, forKey: .data) + case .response(let string): + try container.encode(string, forKey: .data) + } + } + + enum CodingKeys: String, CodingKey { + case type, name, target, data + } + + func dataString() -> String { + return (self.data.stringValue()) + } +} + +//struct Message: Codable { +// var type: String +// var name: String? +// var target: String? +// var data: String? +//} diff --git a/iOS/Ringo/Ringo/WebRTC/Services/SignalingClient.swift b/iOS/Ringo/Ringo/WebRTC/Services/SignalingClient.swift new file mode 100644 index 00000000..44a143b1 --- /dev/null +++ b/iOS/Ringo/Ringo/WebRTC/Services/SignalingClient.swift @@ -0,0 +1,169 @@ +// +// SignalClient.swift +// WebRTC +// +// Created by Stasel on 20/05/2018. +// Copyright © 2018 Stasel. All rights reserved. +// + +import Foundation +import WebRTC + +protocol SignalClientDelegate: AnyObject { + func signalClientDidConnect(_ signalClient: SignalingClient) + func signalClientDidDisconnect(_ signalClient: SignalingClient) + func signalClient(_ signalClient: SignalingClient, didReceiveRemoteSdp sdp: RTCSessionDescription) + func signalClient(_ signalClient: SignalingClient, didReceiveCandidate candidate: RTCIceCandidate) + func signalClient(_ signalClient: SignalingClient, didReceiveCallResponse response: String) + func signalClient(_ signalClient: SignalingClient, didReceiveTranslation msg: String, language: String) +} + +final class SignalingClient { + + private let decoder = JSONDecoder() + private let encoder = JSONEncoder() + private let webSocket: WebSocketProvider + weak var delegate: SignalClientDelegate? + + init(webSocket: WebSocketProvider) { + self.webSocket = webSocket + } + + func connect() { + self.webSocket.delegate = self + self.webSocket.connect() + } + + func store(id: String) { + let message = ["type":"store_user","name":id] + do { + let dataMessage = try self.encoder.encode(message) + +// self.webSocket.send(data: dataMessage) +// debugPrint(String(data: dataMessage, encoding: .utf8)!) + + let stringMessage = String(data: dataMessage, encoding: .utf8)! + self.webSocket.send(string: stringMessage) + debugPrint(stringMessage) + } + catch { + debugPrint("Warning: Could not encode store message: \(error)") + } + } + + func startcall(id: String, target: String) { + let message = ["type":"start_call","name":id,"target":target] + do { + let dataMessage = try self.encoder.encode(message) + +// self.webSocket.send(data: dataMessage) +// debugPrint(String(data: dataMessage, encoding: .utf8)!) + + let stringMessage = String(data: dataMessage, encoding: .utf8)! + self.webSocket.send(string: stringMessage) + debugPrint(stringMessage) + } + catch { + debugPrint("Warning: Could not encode store message: \(error)") + } + } + + func send(message: Message) { + do { + let dataMessage = try self.encoder.encode(message) + +// self.webSocket.send(data: dataMessage) +// print(String(data: dataMessage, encoding: .utf8)!) + + let stringMessage = String(data: dataMessage, encoding: .utf8)! + self.webSocket.send(string: stringMessage) +// print("msg: " + stringMessage) + } + catch { + debugPrint("Warning: Could not encode sdp: \(error)") + } + } + +// func send(candidate rtcIceCandidate: RTCIceCandidate) { +// let message = Message.candidate(IceCandidate(from: rtcIceCandidate)) +// do { +// let dataMessage = try self.encoder.encode(message) +//// self.webSocket.send(data: dataMessage) +// +// let stringMessage = String(data: dataMessage, encoding: .utf8)! +// self.webSocket.send(string: stringMessage) +// print(stringMessage) +// } +// catch { +// debugPrint("Warning: Could not encode candidate: \(error)") +// } +// } +} + + +extension SignalingClient: WebSocketProviderDelegate { + func webSocketDidConnect(_ webSocket: WebSocketProvider) { + self.delegate?.signalClientDidConnect(self) + } + + func webSocketDidDisconnect(_ webSocket: WebSocketProvider) { + self.delegate?.signalClientDidDisconnect(self) + + // try to reconnect every two seconds + DispatchQueue.global().asyncAfter(deadline: .now() + 2) { + debugPrint("Trying to reconnect to signaling server...") + self.webSocket.connect() + } + } + + func webSocket(_ webSocket: WebSocketProvider, didReceiveData data: Data) { + let message: Message + do { + message = try self.decoder.decode(Message.self, from: data) + } + catch { + debugPrint("Warning: Could not decode incoming message: \(error)") + return + } + +// switch message { +// case .candidate(let iceCandidate): +// self.delegate?.signalClient(self, didReceiveCandidate: iceCandidate.rtcIceCandidate) +// case .sdp(let sessionDescription): +// self.delegate?.signalClient(self, didReceiveRemoteSdp: sessionDescription.rtcSessionDescription) +// } + + switch message.type { + case .call_response: + debugPrint("call_response") +// debugPrint(message) + self.delegate?.signalClient(self, didReceiveCallResponse: message.dataString()) + case .offer_received,.answer_received: + debugPrint("received") +// debugPrint(message) + switch message.data { + case .sdp(let sessionDescription): + self.delegate?.signalClient(self, didReceiveRemoteSdp: sessionDescription.rtcSessionDescription) + default: + print("??") + } + case .ice_candidate: + debugPrint("ice_candidate") +// debugPrint(message) + switch message.data { + case .candidate(let iceCandidate): + self.delegate?.signalClient(self, didReceiveCandidate: iceCandidate.rtcIceCandidate) + default: + print("????") + } + case .translate_message: + debugPrint("receive trans msg") + debugPrint(message) + self.delegate?.signalClient(self, didReceiveTranslation: message.dataString(), language: message.target!) + default: + debugPrint("message.type is nothing") + debugPrint(message) + } + + } +} diff --git a/iOS/Ringo/Ringo/WebRTC/Services/WebRTCClient.swift b/iOS/Ringo/Ringo/WebRTC/Services/WebRTCClient.swift new file mode 100644 index 00000000..e8320ef2 --- /dev/null +++ b/iOS/Ringo/Ringo/WebRTC/Services/WebRTCClient.swift @@ -0,0 +1,334 @@ +// +// WebRTCClient.swift +// WebRTC +// +// Created by Stasel on 20/05/2018. +// Copyright © 2018 Stasel. All rights reserved. +// + +import Foundation +import WebRTC + +protocol WebRTCClientDelegate: AnyObject { + func webRTCClient(_ client: WebRTCClient, didDiscoverLocalCandidate candidate: RTCIceCandidate) + func webRTCClient(_ client: WebRTCClient, didChangeConnectionState state: RTCIceConnectionState) + func webRTCClient(_ client: WebRTCClient, didReceiveData data: Data) +} + +final class WebRTCClient: NSObject { + + // The `RTCPeerConnectionFactory` is in charge of creating new RTCPeerConnection instances. + // A new RTCPeerConnection should be created every new call, but the factory is shared. + private static let factory: RTCPeerConnectionFactory = { + RTCInitializeSSL() + let videoEncoderFactory = RTCDefaultVideoEncoderFactory() + let videoDecoderFactory = RTCDefaultVideoDecoderFactory() + return RTCPeerConnectionFactory(encoderFactory: videoEncoderFactory, decoderFactory: videoDecoderFactory) + }() + + weak var delegate: WebRTCClientDelegate? + private let peerConnection: RTCPeerConnection + private let rtcAudioSession = RTCAudioSession.sharedInstance() + private let audioQueue = DispatchQueue(label: "audio") + private let mediaConstrains = [kRTCMediaConstraintsOfferToReceiveAudio: kRTCMediaConstraintsValueTrue, + kRTCMediaConstraintsOfferToReceiveVideo: kRTCMediaConstraintsValueTrue] + private var videoCapturer: RTCVideoCapturer? + private var localVideoTrack: RTCVideoTrack? + private var remoteVideoTrack: RTCVideoTrack? + private var localDataChannel: RTCDataChannel? + private var remoteDataChannel: RTCDataChannel? + + @available(*, unavailable) + override init() { + fatalError("WebRTCClient:init is unavailable") + } + + required init(iceServers: [RTCIceServer]) { + let config = RTCConfiguration() + config.iceServers = iceServers + + // Unified plan is more superior than planB + config.sdpSemantics = .unifiedPlan + + // gatherContinually will let WebRTC to listen to any network changes and send any new candidates to the other client + config.continualGatheringPolicy = .gatherContinually + + // Define media constraints. DtlsSrtpKeyAgreement is required to be true to be able to connect with web browsers. + let constraints = RTCMediaConstraints(mandatoryConstraints: nil, + optionalConstraints: ["DtlsSrtpKeyAgreement":kRTCMediaConstraintsValueTrue]) + + guard let peerConnection = WebRTCClient.factory.peerConnection(with: config, constraints: constraints, delegate: nil) else { + fatalError("Could not create new RTCPeerConnection") + } + + self.peerConnection = peerConnection + + super.init() + self.createMediaSenders() + self.configureAudioSession() + self.peerConnection.delegate = self + } + + // MARK: Signaling + func offer(completion: @escaping (_ sdp: RTCSessionDescription) -> Void) { + let constrains = RTCMediaConstraints(mandatoryConstraints: self.mediaConstrains, + optionalConstraints: nil) + self.peerConnection.offer(for: constrains) { (sdp, error) in + guard let sdp = sdp else { + return + } + + self.peerConnection.setLocalDescription(sdp, completionHandler: { (error) in + completion(sdp) + }) + } + } + + func answer(completion: @escaping (_ sdp: RTCSessionDescription) -> Void) { + let constrains = RTCMediaConstraints(mandatoryConstraints: self.mediaConstrains, + optionalConstraints: nil) + self.peerConnection.answer(for: constrains) { (sdp, error) in + guard let sdp = sdp else { + return + } + + self.peerConnection.setLocalDescription(sdp, completionHandler: { (error) in + completion(sdp) + }) + } + } + + func set(remoteSdp: RTCSessionDescription, completion: @escaping (Error?) -> ()) { + self.peerConnection.setRemoteDescription(remoteSdp, completionHandler: completion) + } + + func set(remoteCandidate: RTCIceCandidate, completion: @escaping (Error?) -> ()) { + self.peerConnection.add(remoteCandidate, completionHandler: completion) + } + + // MARK: Media + func startCaptureLocalVideo(renderer: RTCVideoRenderer) { + guard let capturer = self.videoCapturer as? RTCCameraVideoCapturer else { + return + } + + guard + let frontCamera = (RTCCameraVideoCapturer.captureDevices().first { $0.position == .front }), + + // choose highest res + let format = (RTCCameraVideoCapturer.supportedFormats(for: frontCamera).sorted { (f1, f2) -> Bool in + let width1 = CMVideoFormatDescriptionGetDimensions(f1.formatDescription).width + let width2 = CMVideoFormatDescriptionGetDimensions(f2.formatDescription).width + return width1 < width2 + }).last, + + // choose highest fps + let fps = (format.videoSupportedFrameRateRanges.sorted { return $0.maxFrameRate < $1.maxFrameRate }.last) else { + return + } + + capturer.startCapture(with: frontCamera, + format: format, + fps: Int(fps.maxFrameRate)) + + self.localVideoTrack?.add(renderer) + } + + func renderRemoteVideo(to renderer: RTCVideoRenderer) { + self.remoteVideoTrack?.add(renderer) + } + + private func configureAudioSession() { + self.rtcAudioSession.lockForConfiguration() + do { + try self.rtcAudioSession.setCategory(AVAudioSession.Category.playAndRecord) + try self.rtcAudioSession.setMode(AVAudioSession.Mode.voiceChat) + } catch let error { + debugPrint("Error changeing AVAudioSession category: \(error)") + } + self.rtcAudioSession.unlockForConfiguration() + } + + private func createMediaSenders() { + let streamId = "stream" + + // Audio + let audioTrack = self.createAudioTrack() + self.peerConnection.add(audioTrack, streamIds: [streamId]) + + // Video + let videoTrack = self.createVideoTrack() + self.localVideoTrack = videoTrack + self.peerConnection.add(videoTrack, streamIds: [streamId]) + self.remoteVideoTrack = self.peerConnection.transceivers.first { $0.mediaType == .video }?.receiver.track as? RTCVideoTrack + + // Data + if let dataChannel = createDataChannel() { + dataChannel.delegate = self + self.localDataChannel = dataChannel + } + } + + private func createAudioTrack() -> RTCAudioTrack { + let audioConstrains = RTCMediaConstraints(mandatoryConstraints: nil, optionalConstraints: nil) + let audioSource = WebRTCClient.factory.audioSource(with: audioConstrains) + let audioTrack = WebRTCClient.factory.audioTrack(with: audioSource, trackId: "audio0") + return audioTrack + } + + private func createVideoTrack() -> RTCVideoTrack { + let videoSource = WebRTCClient.factory.videoSource() + + #if targetEnvironment(simulator) + self.videoCapturer = RTCFileVideoCapturer(delegate: videoSource) + #else + self.videoCapturer = RTCCameraVideoCapturer(delegate: videoSource) + #endif + + let videoTrack = WebRTCClient.factory.videoTrack(with: videoSource, trackId: "video0") + return videoTrack + } + + // MARK: Data Channels + private func createDataChannel() -> RTCDataChannel? { + let config = RTCDataChannelConfiguration() + guard let dataChannel = self.peerConnection.dataChannel(forLabel: "WebRTCData", configuration: config) else { + debugPrint("Warning: Couldn't create data channel.") + return nil + } + return dataChannel + } + + func sendData(_ data: Data) { + let buffer = RTCDataBuffer(data: data, isBinary: true) + self.remoteDataChannel?.sendData(buffer) + } +} + +extension WebRTCClient: RTCPeerConnectionDelegate { + + func peerConnection(_ peerConnection: RTCPeerConnection, didChange stateChanged: RTCSignalingState) { + debugPrint("peerConnection new signaling state: \(stateChanged)") + } + + func peerConnection(_ peerConnection: RTCPeerConnection, didAdd stream: RTCMediaStream) { + debugPrint("peerConnection did add stream") + } + + func peerConnection(_ peerConnection: RTCPeerConnection, didRemove stream: RTCMediaStream) { + debugPrint("peerConnection did remove stream") + } + + func peerConnectionShouldNegotiate(_ peerConnection: RTCPeerConnection) { + debugPrint("peerConnection should negotiate") + } + + func peerConnection(_ peerConnection: RTCPeerConnection, didChange newState: RTCIceConnectionState) { + debugPrint("peerConnection new connection state: \(newState)") + self.delegate?.webRTCClient(self, didChangeConnectionState: newState) + } + + func peerConnection(_ peerConnection: RTCPeerConnection, didChange newState: RTCIceGatheringState) { + debugPrint("peerConnection new gathering state: \(newState)") + } + + func peerConnection(_ peerConnection: RTCPeerConnection, didGenerate candidate: RTCIceCandidate) { + self.delegate?.webRTCClient(self, didDiscoverLocalCandidate: candidate) + } + + func peerConnection(_ peerConnection: RTCPeerConnection, didRemove candidates: [RTCIceCandidate]) { + debugPrint("peerConnection did remove candidate(s)") + } + + func peerConnection(_ peerConnection: RTCPeerConnection, didOpen dataChannel: RTCDataChannel) { + debugPrint("peerConnection did open data channel") + self.remoteDataChannel = dataChannel + } +} +extension WebRTCClient { + private func setTrackEnabled(_ type: T.Type, isEnabled: Bool) { + peerConnection.transceivers + .compactMap { return $0.sender.track as? T } + .forEach { $0.isEnabled = isEnabled } + } +} + +// MARK: - Video control +extension WebRTCClient { + func hideVideo() { + self.setVideoEnabled(false) + } + func showVideo() { + self.setVideoEnabled(true) + } + private func setVideoEnabled(_ isEnabled: Bool) { + setTrackEnabled(RTCVideoTrack.self, isEnabled: isEnabled) + } +} +// MARK:- Audio control +extension WebRTCClient { + func muteAudio() { + self.setAudioEnabled(false) + } + + func unmuteAudio() { + self.setAudioEnabled(true) + } + + // Fallback to the default playing device: headphones/bluetooth/ear speaker + func speakerOff() { + self.audioQueue.async { [weak self] in + guard let self = self else { + return + } + + self.rtcAudioSession.lockForConfiguration() + do { + try self.rtcAudioSession.setCategory(AVAudioSession.Category.playAndRecord) + try self.rtcAudioSession.overrideOutputAudioPort(.none) + } catch let error { + debugPrint("Error setting AVAudioSession category: \(error)") + } + self.rtcAudioSession.unlockForConfiguration() + } + } + + // Force speaker + func speakerOn() { + self.audioQueue.async { [weak self] in + guard let self = self else { + return + } + + self.rtcAudioSession.lockForConfiguration() + do { + try self.rtcAudioSession.setCategory(AVAudioSession.Category.playAndRecord) + try self.rtcAudioSession.overrideOutputAudioPort(.speaker) + try self.rtcAudioSession.setActive(true) + } catch let error { + debugPrint("Couldn't force audio to speaker: \(error)") + } + self.rtcAudioSession.unlockForConfiguration() + } + } + + private func setAudioEnabled(_ isEnabled: Bool) { + setTrackEnabled(RTCAudioTrack.self, isEnabled: isEnabled) + } +} + +extension WebRTCClient: RTCDataChannelDelegate { + func dataChannelDidChangeState(_ dataChannel: RTCDataChannel) { + debugPrint("dataChannel did change state: \(dataChannel.readyState)") + } + + func dataChannel(_ dataChannel: RTCDataChannel, didReceiveMessageWith buffer: RTCDataBuffer) { + self.delegate?.webRTCClient(self, didReceiveData: buffer.data) + } +} + +extension WebRTCClient { + func endCall() { + peerConnection.close() + } +} diff --git a/iOS/Ringo/Ringo/WebRTC/Services/WebSocketProvider/NativeWebSocket.swift b/iOS/Ringo/Ringo/WebRTC/Services/WebSocketProvider/NativeWebSocket.swift new file mode 100644 index 00000000..7d88335f --- /dev/null +++ b/iOS/Ringo/Ringo/WebRTC/Services/WebSocketProvider/NativeWebSocket.swift @@ -0,0 +1,76 @@ +// +// NativeSocketProvider.swift +// WebRTC-Demo +// +// Created by stasel on 15/07/2019. +// Copyright © 2019 stasel. All rights reserved. +// + +import Foundation + +@available(iOS 13.0, *) +class NativeWebSocket: NSObject, WebSocketProvider { + + var delegate: WebSocketProviderDelegate? + private let url: URL + private var socket: URLSessionWebSocketTask? + private lazy var urlSession: URLSession = URLSession(configuration: .default, delegate: self, delegateQueue: nil) + + init(url: URL) { + self.url = url + super.init() + } + + func connect() { + let socket = urlSession.webSocketTask(with: url) + socket.resume() + self.socket = socket + self.readMessage() + } + + func send(data: Data) { + self.socket?.send(.data(data)) { _ in } + } + + func send(string: String){ + self.socket?.send(.string(string)) { _ in } + } + + private func readMessage() { + self.socket?.receive { [weak self] message in + guard let self = self else { return } + + switch message { + case .success(.string(let stringdata)): + print(stringdata) + let strdata = stringdata.data(using: .utf8) + self.delegate?.webSocket(self, didReceiveData: strdata!) + self.readMessage() + + case .success: + debugPrint("Warning: Expected to receive data format but received a string. Check the websocket server config.") + self.readMessage() + + case .failure: + self.disconnect() + } + } + } + + private func disconnect() { + self.socket?.cancel() + self.socket = nil + self.delegate?.webSocketDidDisconnect(self) + } +} + +@available(iOS 13.0, *) +extension NativeWebSocket: URLSessionWebSocketDelegate, URLSessionDelegate { + func urlSession(_ session: URLSession, webSocketTask: URLSessionWebSocketTask, didOpenWithProtocol protocol: String?) { + self.delegate?.webSocketDidConnect(self) + } + + func urlSession(_ session: URLSession, webSocketTask: URLSessionWebSocketTask, didCloseWith closeCode: URLSessionWebSocketTask.CloseCode, reason: Data?) { + self.disconnect() + } +} diff --git a/iOS/Ringo/Ringo/WebRTC/Services/WebSocketProvider/StarscreamProvider.swift b/iOS/Ringo/Ringo/WebRTC/Services/WebSocketProvider/StarscreamProvider.swift new file mode 100644 index 00000000..051643b7 --- /dev/null +++ b/iOS/Ringo/Ringo/WebRTC/Services/WebSocketProvider/StarscreamProvider.swift @@ -0,0 +1,55 @@ +// +// StarscreamProvider.swift +// WebRTC-Demo +// +// Created by stasel on 15/07/2019. +// Copyright © 2019 stasel. All rights reserved. +// + +import Foundation +import Starscream + +class StarscreamWebSocket: WebSocketProvider { + + var delegate: WebSocketProviderDelegate? + private let socket: WebSocket + + init(url: URL) { + self.socket = WebSocket(request: URLRequest(url: url)) + self.socket.delegate = self + } + + func connect() { + self.socket.connect() + } + + func send(data: Data) { + self.socket.write(data: data) + } + + func send(string: String) { + self.socket.write(string: string) + } +} + +extension StarscreamWebSocket: Starscream.WebSocketDelegate { + func didReceive(event: Starscream.WebSocketEvent, client: Starscream.WebSocketClient) { + print("idk") + } + + + func didReceive(event: Starscream.WebSocketEvent, client: Starscream.WebSocket) { + switch event { + case .connected: + self.delegate?.webSocketDidConnect(self) + case .disconnected: + self.delegate?.webSocketDidDisconnect(self) + case .text: + debugPrint("Warning: Expected to receive data format but received a string. Check the websocket server config.") + case .binary(let data): + self.delegate?.webSocket(self, didReceiveData: data) + default: + break + } + } +} diff --git a/iOS/Ringo/Ringo/WebRTC/Services/WebSocketProvider/WebSocketProvider.swift b/iOS/Ringo/Ringo/WebRTC/Services/WebSocketProvider/WebSocketProvider.swift new file mode 100644 index 00000000..1bd8b3eb --- /dev/null +++ b/iOS/Ringo/Ringo/WebRTC/Services/WebSocketProvider/WebSocketProvider.swift @@ -0,0 +1,22 @@ +// +// File.swift +// WebRTC-Demo +// +// Created by stasel on 15/07/2019. +// Copyright © 2019 stasel. All rights reserved. +// + +import Foundation + +protocol WebSocketProvider: AnyObject { + var delegate: WebSocketProviderDelegate? { get set } + func connect() + func send(data: Data) + func send(string: String) +} + +protocol WebSocketProviderDelegate: AnyObject { + func webSocketDidConnect(_ webSocket: WebSocketProvider) + func webSocketDidDisconnect(_ webSocket: WebSocketProvider) + func webSocket(_ webSocket: WebSocketProvider, didReceiveData data: Data) +}