@kaleyra/video-react-native-module 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +292 -0
  3. package/android/build.gradle +100 -0
  4. package/android/gradle.properties +9 -0
  5. package/android/settings.gradle +6 -0
  6. package/android/src/main/AndroidManifest.xml +1 -0
  7. package/android/src/main/assets/kaleyra_video_wrapper_info.txt +1 -0
  8. package/android/src/main/java/com/kaleyra/video_react_native_module/ReactNativeAccessTokenProvider.kt +22 -0
  9. package/android/src/main/java/com/kaleyra/video_react_native_module/ReactNativeContextContainer.kt +9 -0
  10. package/android/src/main/java/com/kaleyra/video_react_native_module/ReactNativeVideoHybridBridge.kt +30 -0
  11. package/android/src/main/java/com/kaleyra/video_react_native_module/VideoNativeEmitter.kt +45 -0
  12. package/android/src/main/java/com/kaleyra/video_react_native_module/VideoNativeModule.kt +109 -0
  13. package/android/src/main/java/com/kaleyra/video_react_native_module/VideoReactPackage.kt +20 -0
  14. package/index.ts +47 -0
  15. package/ios/PluginInfo/_KaleyraVideoHybridVersionInfo.swift +31 -0
  16. package/ios/ReactEvents/ReactNativeEventEmitter.swift +31 -0
  17. package/ios/ReactEvents/VideoNativeEmitter.m +17 -0
  18. package/ios/ReactEvents/VideoNativeEmitter.swift +42 -0
  19. package/ios/ReactNativePlugin-Bridging-Header.h +5 -0
  20. package/ios/ReactNativePlugin.xcodeproj/project.pbxproj +301 -0
  21. package/ios/VideoNativeModule.m +45 -0
  22. package/ios/VideoNativeModule.swift +154 -0
  23. package/lib/commonjs/index.js +12 -0
  24. package/lib/commonjs/native-bridge/TypeScript/Environments.js +41 -0
  25. package/lib/commonjs/native-bridge/TypeScript/Events.js +46 -0
  26. package/lib/commonjs/native-bridge/TypeScript/Regions.js +47 -0
  27. package/lib/commonjs/native-bridge/TypeScript/UserDetailsFormatValidator.js +32 -0
  28. package/lib/commonjs/native-bridge/TypeScript/errors/IllegalArgumentError.js +12 -0
  29. package/lib/commonjs/native-bridge/TypeScript/types/AccessTokenRequest.js +4 -0
  30. package/lib/commonjs/native-bridge/TypeScript/types/AccessTokenResponse.js +36 -0
  31. package/lib/commonjs/native-bridge/TypeScript/types/AudioCallOptions.js +4 -0
  32. package/lib/commonjs/native-bridge/TypeScript/types/AudioCallType.js +19 -0
  33. package/lib/commonjs/native-bridge/TypeScript/types/CallDisplayMode.js +23 -0
  34. package/lib/commonjs/native-bridge/TypeScript/types/CallKitConfiguration.js +4 -0
  35. package/lib/commonjs/native-bridge/TypeScript/types/CallOptions.js +4 -0
  36. package/lib/commonjs/native-bridge/TypeScript/types/CallType.js +23 -0
  37. package/lib/commonjs/native-bridge/TypeScript/types/ChatToolConfiguration.js +4 -0
  38. package/lib/commonjs/native-bridge/TypeScript/types/CreateCallOptions.js +4 -0
  39. package/lib/commonjs/native-bridge/TypeScript/types/Environment.js +4 -0
  40. package/lib/commonjs/native-bridge/TypeScript/types/IosConfiguration.js +4 -0
  41. package/lib/commonjs/native-bridge/TypeScript/types/KaleyraVideoConfiguration.js +4 -0
  42. package/lib/commonjs/native-bridge/TypeScript/types/RecordingType.js +23 -0
  43. package/lib/commonjs/native-bridge/TypeScript/types/Region.js +4 -0
  44. package/lib/commonjs/native-bridge/TypeScript/types/ScreenShareToolConfiguration.js +4 -0
  45. package/lib/commonjs/native-bridge/TypeScript/types/Session.js +4 -0
  46. package/lib/commonjs/native-bridge/TypeScript/types/Tools.js +4 -0
  47. package/lib/commonjs/native-bridge/TypeScript/types/UserDetails.js +4 -0
  48. package/lib/commonjs/native-bridge/TypeScript/types/UserDetailsFormat.js +4 -0
  49. package/lib/commonjs/native-bridge/TypeScript/types/VoipHandlingStrategy.js +19 -0
  50. package/lib/commonjs/src/KaleyraVideo.js +259 -0
  51. package/lib/commonjs/src/ReactNativeEventEmitter.js +40 -0
  52. package/lib/commonjs/src/events/Events.js +4 -0
  53. package/lib/module/index.js +2 -0
  54. package/lib/module/native-bridge/TypeScript/Environments.js +37 -0
  55. package/lib/module/native-bridge/TypeScript/Events.js +43 -0
  56. package/lib/module/native-bridge/TypeScript/Regions.js +43 -0
  57. package/lib/module/native-bridge/TypeScript/UserDetailsFormatValidator.js +28 -0
  58. package/lib/module/native-bridge/TypeScript/errors/IllegalArgumentError.js +8 -0
  59. package/lib/module/native-bridge/TypeScript/types/AccessTokenRequest.js +3 -0
  60. package/lib/module/native-bridge/TypeScript/types/AccessTokenResponse.js +32 -0
  61. package/lib/module/native-bridge/TypeScript/types/AudioCallOptions.js +3 -0
  62. package/lib/module/native-bridge/TypeScript/types/AudioCallType.js +16 -0
  63. package/lib/module/native-bridge/TypeScript/types/CallDisplayMode.js +20 -0
  64. package/lib/module/native-bridge/TypeScript/types/CallKitConfiguration.js +3 -0
  65. package/lib/module/native-bridge/TypeScript/types/CallOptions.js +3 -0
  66. package/lib/module/native-bridge/TypeScript/types/CallType.js +20 -0
  67. package/lib/module/native-bridge/TypeScript/types/ChatToolConfiguration.js +3 -0
  68. package/lib/module/native-bridge/TypeScript/types/CreateCallOptions.js +3 -0
  69. package/lib/module/native-bridge/TypeScript/types/Environment.js +3 -0
  70. package/lib/module/native-bridge/TypeScript/types/IosConfiguration.js +3 -0
  71. package/lib/module/native-bridge/TypeScript/types/KaleyraVideoConfiguration.js +3 -0
  72. package/lib/module/native-bridge/TypeScript/types/RecordingType.js +20 -0
  73. package/lib/module/native-bridge/TypeScript/types/Region.js +3 -0
  74. package/lib/module/native-bridge/TypeScript/types/ScreenShareToolConfiguration.js +3 -0
  75. package/lib/module/native-bridge/TypeScript/types/Session.js +3 -0
  76. package/lib/module/native-bridge/TypeScript/types/Tools.js +3 -0
  77. package/lib/module/native-bridge/TypeScript/types/UserDetails.js +3 -0
  78. package/lib/module/native-bridge/TypeScript/types/UserDetailsFormat.js +3 -0
  79. package/lib/module/native-bridge/TypeScript/types/VoipHandlingStrategy.js +16 -0
  80. package/lib/module/src/KaleyraVideo.js +249 -0
  81. package/lib/module/src/ReactNativeEventEmitter.js +36 -0
  82. package/lib/module/src/events/Events.js +3 -0
  83. package/lib/typescript/index.d.ts +2 -0
  84. package/lib/typescript/native-bridge/TypeScript/Environments.d.ts +28 -0
  85. package/lib/typescript/native-bridge/TypeScript/Events.d.ts +40 -0
  86. package/lib/typescript/native-bridge/TypeScript/Regions.d.ts +32 -0
  87. package/lib/typescript/native-bridge/TypeScript/UserDetailsFormatValidator.d.ts +4 -0
  88. package/lib/typescript/native-bridge/TypeScript/errors/IllegalArgumentError.d.ts +6 -0
  89. package/lib/typescript/native-bridge/TypeScript/types/AccessTokenRequest.d.ts +4 -0
  90. package/lib/typescript/native-bridge/TypeScript/types/AccessTokenResponse.d.ts +12 -0
  91. package/lib/typescript/native-bridge/TypeScript/types/AudioCallOptions.d.ts +11 -0
  92. package/lib/typescript/native-bridge/TypeScript/types/AudioCallType.d.ts +13 -0
  93. package/lib/typescript/native-bridge/TypeScript/types/CallDisplayMode.d.ts +17 -0
  94. package/lib/typescript/native-bridge/TypeScript/types/CallKitConfiguration.d.ts +26 -0
  95. package/lib/typescript/native-bridge/TypeScript/types/CallOptions.d.ts +13 -0
  96. package/lib/typescript/native-bridge/TypeScript/types/CallType.d.ts +17 -0
  97. package/lib/typescript/native-bridge/TypeScript/types/ChatToolConfiguration.d.ts +15 -0
  98. package/lib/typescript/native-bridge/TypeScript/types/CreateCallOptions.d.ts +15 -0
  99. package/lib/typescript/native-bridge/TypeScript/types/Environment.d.ts +9 -0
  100. package/lib/typescript/native-bridge/TypeScript/types/IosConfiguration.d.ts +23 -0
  101. package/lib/typescript/native-bridge/TypeScript/types/KaleyraVideoConfiguration.d.ts +33 -0
  102. package/lib/typescript/native-bridge/TypeScript/types/RecordingType.d.ts +17 -0
  103. package/lib/typescript/native-bridge/TypeScript/types/Region.d.ts +9 -0
  104. package/lib/typescript/native-bridge/TypeScript/types/ScreenShareToolConfiguration.d.ts +19 -0
  105. package/lib/typescript/native-bridge/TypeScript/types/Session.d.ts +16 -0
  106. package/lib/typescript/native-bridge/TypeScript/types/Tools.d.ts +42 -0
  107. package/lib/typescript/native-bridge/TypeScript/types/UserDetails.d.ts +29 -0
  108. package/lib/typescript/native-bridge/TypeScript/types/UserDetailsFormat.d.ts +19 -0
  109. package/lib/typescript/native-bridge/TypeScript/types/VoipHandlingStrategy.d.ts +13 -0
  110. package/lib/typescript/src/KaleyraVideo.d.ts +125 -0
  111. package/lib/typescript/src/ReactNativeEventEmitter.d.ts +15 -0
  112. package/lib/typescript/src/events/Events.d.ts +37 -0
  113. package/native-bridge/LICENSE +165 -0
  114. package/native-bridge/TypeScript/Environments.ts +44 -0
  115. package/native-bridge/TypeScript/Events.ts +43 -0
  116. package/native-bridge/TypeScript/Regions.ts +51 -0
  117. package/native-bridge/TypeScript/UserDetailsFormatValidator.ts +35 -0
  118. package/native-bridge/TypeScript/errors/IllegalArgumentError.ts +9 -0
  119. package/native-bridge/TypeScript/types/AccessTokenRequest.ts +7 -0
  120. package/native-bridge/TypeScript/types/AccessTokenResponse.ts +41 -0
  121. package/native-bridge/TypeScript/types/AudioCallOptions.ts +15 -0
  122. package/native-bridge/TypeScript/types/AudioCallType.ts +17 -0
  123. package/native-bridge/TypeScript/types/CallDisplayMode.ts +22 -0
  124. package/native-bridge/TypeScript/types/CallKitConfiguration.ts +32 -0
  125. package/native-bridge/TypeScript/types/CallOptions.ts +18 -0
  126. package/native-bridge/TypeScript/types/CallType.ts +22 -0
  127. package/native-bridge/TypeScript/types/ChatToolConfiguration.ts +21 -0
  128. package/native-bridge/TypeScript/types/CreateCallOptions.ts +20 -0
  129. package/native-bridge/TypeScript/types/Environment.ts +12 -0
  130. package/native-bridge/TypeScript/types/IosConfiguration.ts +29 -0
  131. package/native-bridge/TypeScript/types/KaleyraVideoConfiguration.ts +42 -0
  132. package/native-bridge/TypeScript/types/RecordingType.ts +22 -0
  133. package/native-bridge/TypeScript/types/Region.ts +12 -0
  134. package/native-bridge/TypeScript/types/ScreenShareToolConfiguration.ts +24 -0
  135. package/native-bridge/TypeScript/types/Session.ts +20 -0
  136. package/native-bridge/TypeScript/types/Tools.ts +50 -0
  137. package/native-bridge/TypeScript/types/UserDetails.ts +37 -0
  138. package/native-bridge/TypeScript/types/UserDetailsFormat.ts +23 -0
  139. package/native-bridge/TypeScript/types/VoipHandlingStrategy.ts +17 -0
  140. package/native-bridge/android/build.gradle +72 -0
  141. package/native-bridge/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  142. package/native-bridge/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  143. package/native-bridge/android/gradle.properties +22 -0
  144. package/native-bridge/android/gradlew +234 -0
  145. package/native-bridge/android/gradlew.bat +89 -0
  146. package/native-bridge/android/settings.gradle +1 -0
  147. package/native-bridge/android/src/main/AndroidManifest.xml +1 -0
  148. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/AccessTokenProvider.kt +8 -0
  149. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/CallOptionsProxy.kt +9 -0
  150. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/ContextContainer.kt +10 -0
  151. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/DTOs.kt +407 -0
  152. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/SDKAccessTokenProviderProxy.kt +16 -0
  153. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/VideoHybridBridge.kt +21 -0
  154. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/VideoSDKHybridBridge.kt +64 -0
  155. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/configurator/CachedSDKConfigurator.kt +15 -0
  156. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/configurator/VideoSDKConfigurator.kt +46 -0
  157. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/connector/CachedUserConnector.kt +15 -0
  158. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/connector/VideoSDKCachedUserConnector.kt +60 -0
  159. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/Events.kt +29 -0
  160. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/EventsEmitter.kt +8 -0
  161. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/EventsReporter.kt +9 -0
  162. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/CallEventsReporter.kt +54 -0
  163. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/ChatEventsReporter.kt +43 -0
  164. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/CrossPlatformModuleStatus.kt +29 -0
  165. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/ModuleEventsReporter.kt +34 -0
  166. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/events/reporter/SDKEventsReporter.kt +63 -0
  167. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/CallDisplayExtension.kt +15 -0
  168. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ConfigurationExtension.kt +39 -0
  169. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/EnvironmentExtension.kt +12 -0
  170. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/RecordingTypeExtension.kt +15 -0
  171. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/RegionExtension.kt +13 -0
  172. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ScreenShareToolConfigurationExtension.kt +15 -0
  173. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/ToolsExtension.kt +95 -0
  174. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/extensions/UserExtensions.kt +35 -0
  175. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/notifications/KaleyraVideoNotificationReceiver.kt +139 -0
  176. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/notifications/KaleyraVideoNotificationService.kt +85 -0
  177. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/ConfigurationEntity.kt +27 -0
  178. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/ConnectedUserEntity.kt +30 -0
  179. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/Converters.kt +25 -0
  180. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/UserDetailsDao.kt +21 -0
  181. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/UserDetailsEntity.kt +22 -0
  182. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/repository/VideoHybridBridgeRepository.kt +39 -0
  183. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/ui/SDKUserInterfacePresenter.kt +49 -0
  184. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/ui/UserInterfacePresenter.kt +14 -0
  185. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/CachedUserDetails.kt +18 -0
  186. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/CachedUserDetailsFormatter.kt +59 -0
  187. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/user_details/SDKCachedUserDetails.kt +74 -0
  188. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/utils/CaseInsensitiveEnumTypeAdapterFactory.kt +48 -0
  189. package/native-bridge/android/src/main/java/com/kaleyra/video_hybrid_native_bridge/utils/TLSSocketFactoryCompat.kt +76 -0
  190. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/project.pbxproj +1399 -0
  191. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  192. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  193. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/xcshareddata/IDETemplateMacros.plist +9 -0
  194. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcodeproj/xcshareddata/xcschemes/KaleyraVideoHybridNativeBridge.xcscheme +79 -0
  195. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcworkspace/contents.xcworkspacedata +10 -0
  196. package/native-bridge/iOS/KaleyraVideoHybridNativeBridge.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  197. package/native-bridge/iOS/Podfile +28 -0
  198. package/native-bridge/iOS/Podfile.lock +20 -0
  199. package/native-bridge/iOS/Source/Abstractions/BandyerSDKProtocol.swift +24 -0
  200. package/native-bridge/iOS/Source/Abstractions/CallWindowProtocol.swift +18 -0
  201. package/native-bridge/iOS/Source/AccessToken/AccessTokenRequester.swift +9 -0
  202. package/native-bridge/iOS/Source/AccessToken/TokenProvider.swift +78 -0
  203. package/native-bridge/iOS/Source/Broadcast/BroadcastConfigurationPlistReader.swift +49 -0
  204. package/native-bridge/iOS/Source/Concurrency/DispatchQueue+isMain.swift +19 -0
  205. package/native-bridge/iOS/Source/Concurrency/Lock.swift +21 -0
  206. package/native-bridge/iOS/Source/Concurrency/MainQueueDispatcher.swift +23 -0
  207. package/native-bridge/iOS/Source/Concurrency/MainQueueRelay.swift +18 -0
  208. package/native-bridge/iOS/Source/DTOs/AccessTokenRequest+Encodable.swift +27 -0
  209. package/native-bridge/iOS/Source/DTOs/AccessTokenResponse+Decodable.swift +24 -0
  210. package/native-bridge/iOS/Source/DTOs/Array+JSON.swift +6 -0
  211. package/native-bridge/iOS/Source/DTOs/AudioCallOptions+Bandyer.swift +14 -0
  212. package/native-bridge/iOS/Source/DTOs/AudioCallOptions+Decodable.swift +18 -0
  213. package/native-bridge/iOS/Source/DTOs/AudioCallOptions+Equatable.swift +12 -0
  214. package/native-bridge/iOS/Source/DTOs/AudioCallType+Bandyer.swift +18 -0
  215. package/native-bridge/iOS/Source/DTOs/AudioCallType+Decodable.swift +25 -0
  216. package/native-bridge/iOS/Source/DTOs/CallKitConfiguration+Decodable.swift +20 -0
  217. package/native-bridge/iOS/Source/DTOs/CallOptions+Bandyer.swift +14 -0
  218. package/native-bridge/iOS/Source/DTOs/CallOptions+Decodable.swift +16 -0
  219. package/native-bridge/iOS/Source/DTOs/CallOptions+Equatable.swift +12 -0
  220. package/native-bridge/iOS/Source/DTOs/CallType+Bandyer.swift +20 -0
  221. package/native-bridge/iOS/Source/DTOs/CallType+Decodable.swift +27 -0
  222. package/native-bridge/iOS/Source/DTOs/ChatToolConfiguration+Decodable.swift +18 -0
  223. package/native-bridge/iOS/Source/DTOs/CreateCallOptions+Decodable.swift +22 -0
  224. package/native-bridge/iOS/Source/DTOs/CreateCallOptions+Equatable.swift +13 -0
  225. package/native-bridge/iOS/Source/DTOs/CreateCallOptions+Intent.swift +17 -0
  226. package/native-bridge/iOS/Source/DTOs/DTOs.swift +314 -0
  227. package/native-bridge/iOS/Source/DTOs/Environment+Bandyer.swift +20 -0
  228. package/native-bridge/iOS/Source/DTOs/Environment+Decodable.swift +16 -0
  229. package/native-bridge/iOS/Source/DTOs/IosConfiguration+Decodable.swift +18 -0
  230. package/native-bridge/iOS/Source/DTOs/JSONDecodable.swift +27 -0
  231. package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+Bandyer.swift +158 -0
  232. package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+Decodable.swift +28 -0
  233. package/native-bridge/iOS/Source/DTOs/KaleyraVideoConfiguration+UserInterfacePresenterConfiguration.swift +29 -0
  234. package/native-bridge/iOS/Source/DTOs/RecordingType+Bandyer.swift +33 -0
  235. package/native-bridge/iOS/Source/DTOs/RecordingType+Decodable.swift +27 -0
  236. package/native-bridge/iOS/Source/DTOs/Region+Bandyer.swift +22 -0
  237. package/native-bridge/iOS/Source/DTOs/Region+Decodable.swift +16 -0
  238. package/native-bridge/iOS/Source/DTOs/ScreenShareToolConfiguration+Decodable.swift +18 -0
  239. package/native-bridge/iOS/Source/DTOs/Tools+Decodable.swift +24 -0
  240. package/native-bridge/iOS/Source/DTOs/UserDetails+Bandyer.swift +18 -0
  241. package/native-bridge/iOS/Source/DTOs/UserDetails+Decodable.swift +28 -0
  242. package/native-bridge/iOS/Source/DTOs/UserDetailsFormat+Decodable.swift +19 -0
  243. package/native-bridge/iOS/Source/DTOs/VoipHandlingStrategy+Decodable.swift +25 -0
  244. package/native-bridge/iOS/Source/Events/Emitter/EventEmitter.swift +8 -0
  245. package/native-bridge/iOS/Source/Events/Events+CaseIterable.swift +18 -0
  246. package/native-bridge/iOS/Source/Events/Events+Description.swift +28 -0
  247. package/native-bridge/iOS/Source/Events/Events.swift +21 -0
  248. package/native-bridge/iOS/Source/Events/Reporters/CallClientEventsReporter.swift +46 -0
  249. package/native-bridge/iOS/Source/Events/Reporters/ChatClientEventsReporter.swift +46 -0
  250. package/native-bridge/iOS/Source/Events/Reporters/ClientState.swift +61 -0
  251. package/native-bridge/iOS/Source/Events/Reporters/EventsReporter.swift +69 -0
  252. package/native-bridge/iOS/Source/Events/Reporters/PushTokenEventsReporter.swift +34 -0
  253. package/native-bridge/iOS/Source/Extensions/URL+FromString.swift +26 -0
  254. package/native-bridge/iOS/Source/KaleyraVideoHybridNativeBridge.h +14 -0
  255. package/native-bridge/iOS/Source/NativeHybridBridge/VideoHybridNativeBridge.swift +173 -0
  256. package/native-bridge/iOS/Source/NativeHybridBridge/VideoHybridNativeBridgeError.swift +33 -0
  257. package/native-bridge/iOS/Source/UI/KaleyraVideoSDKUserInterfacePresenter.swift +249 -0
  258. package/native-bridge/iOS/Source/UI/Presenters/PresentingViewControllerViewControllerPresenter.swift +44 -0
  259. package/native-bridge/iOS/Source/UI/Presenters/ViewControllerPresenter.swift +17 -0
  260. package/native-bridge/iOS/Source/UI/Presenters/WindowViewControllerPresenter.swift +111 -0
  261. package/native-bridge/iOS/Source/UI/UserInterfacePresenter+MainQueueRelay.swift +30 -0
  262. package/native-bridge/iOS/Source/UI/UserInterfacePresenter.swift +14 -0
  263. package/native-bridge/iOS/Source/User Details/Cache/UsersDetailsCache.swift +36 -0
  264. package/native-bridge/iOS/Source/User Details/Formatter/FormatterProxy.swift +47 -0
  265. package/native-bridge/iOS/Source/User Details/Formatter/UserDetailsFormatter.swift +83 -0
  266. package/native-bridge/iOS/Source/User Details/Providers/UsersDetailsProvider.swift +39 -0
  267. package/package.json +147 -0
  268. package/src/KaleyraVideo.ts +343 -0
  269. package/src/ReactNativeEventEmitter.ts +51 -0
  270. package/src/events/Events.ts +46 -0
  271. package/video-react-native-module.podspec +36 -0
@@ -0,0 +1,407 @@
1
+ package com.kaleyra.video_hybrid_native_bridge
2
+
3
+ data class AccessTokenRequest (
4
+ val requestID: String,
5
+ val userID: String
6
+ )
7
+
8
+ data class AccessTokenResponse (
9
+ val data: String,
10
+ val error: String? = null,
11
+ val requestID: String,
12
+ val success: Boolean
13
+ )
14
+
15
+ /**
16
+ * This class defines the display modes supported per call.
17
+ */
18
+ enum class CallDisplayMode {
19
+ Background,
20
+ Foreground,
21
+ ForegroundPictureInPicture
22
+ }
23
+
24
+ /**
25
+ * Options to be used when creating a call
26
+ */
27
+ data class CreateCallOptions (
28
+ /**
29
+ * Array of callees identifiers to call.
30
+ */
31
+ val callees: List<String>,
32
+
33
+ /**
34
+ * Type of call to create
35
+ */
36
+ val callType: CallType,
37
+
38
+ /**
39
+ * May have three different values, NONE, AUTOMATIC, MANUAL
40
+ * <br/>
41
+ * <br/>
42
+ * <b><font color="blue">default</font>: none</b>
43
+ */
44
+ val recordingType: RecordingType? = null
45
+ )
46
+
47
+ /**
48
+ * This class defines the types of calls supported.
49
+ *
50
+ * Type of call to create
51
+ */
52
+ enum class CallType {
53
+ Audio,
54
+ AudioUpgradable,
55
+ AudioVideo
56
+ }
57
+
58
+ /**
59
+ * Recording type of the call
60
+ *
61
+ * May have three different values, NONE, AUTOMATIC, MANUAL
62
+ * <br/>
63
+ * <br/>
64
+ * <b><font color="blue">default</font>: none</b>
65
+ */
66
+ enum class RecordingType {
67
+ Automatic,
68
+ Manual,
69
+ None
70
+ }
71
+
72
+ /**
73
+ * Generic configuration used for setup
74
+ */
75
+ data class KaleyraVideoConfiguration (
76
+ /**
77
+ * This key will be provided to you by us.
78
+ */
79
+ val appID: String,
80
+
81
+ /**
82
+ * This variable defines the environment where you will be sandbox or production.
83
+ */
84
+ val environment: Environment,
85
+
86
+ /**
87
+ * Define to customize the iOS configuration
88
+ */
89
+ val iosConfig: IosConfiguration? = null,
90
+
91
+ /**
92
+ * Set to true to enable log, default value is false
93
+ */
94
+ val logEnabled: Boolean? = null,
95
+
96
+ /**
97
+ * This variable defines the region where you will be europe, india or us.
98
+ */
99
+ val region: Region,
100
+
101
+ /**
102
+ * Define the tools to use
103
+ */
104
+ val tools: Tools? = null
105
+ )
106
+
107
+ /**
108
+ * An environment where your integration will run
109
+ *
110
+ * This variable defines the environment where you will be sandbox or production.
111
+ */
112
+ data class Environment (
113
+ /**
114
+ * name of the environment
115
+ */
116
+ val name: String
117
+ )
118
+
119
+ /**
120
+ * Configuration for iOS platform
121
+ *
122
+ * Define to customize the iOS configuration
123
+ */
124
+ data class IosConfiguration (
125
+ /**
126
+ * Specify the callkit configuration to enable the usage and it's behaviour
127
+ * <br/>
128
+ * <br/>
129
+ * <b><font color="blue">default</font>: enabled</b>
130
+ */
131
+ val callkit: CallKitConfiguration? = null,
132
+
133
+ /**
134
+ * Specify the voip handling strategy.
135
+ * <br/>
136
+ * This allows you to disable or leave the plugin behaviour for handling the voip
137
+ * notifications.
138
+ * <br/>
139
+ * <br/>
140
+ * <b><font color="blue">default</font>: VoipHandlingStrategy.AUTOMATIC </b>
141
+ */
142
+ val voipHandlingStrategy: VoipHandlingStrategy? = null
143
+ )
144
+
145
+ /**
146
+ * Configuration for callkit
147
+ *
148
+ * Specify the callkit configuration to enable the usage and it's behaviour
149
+ * <br/>
150
+ * <br/>
151
+ * <b><font color="blue">default</font>: enabled</b>
152
+ */
153
+ data class CallKitConfiguration (
154
+ /**
155
+ * The icon resource name to be used in the callkit UI to represent the app
156
+ * <br/>
157
+ * <br/>
158
+ * <b><font color="blue">default</font>: null</b>
159
+ */
160
+ val appIconName: String? = null,
161
+
162
+ /**
163
+ * Set to false to disable
164
+ * <br/>
165
+ * <br/>
166
+ * <b><font color="blue">default</font>: true</b>
167
+ */
168
+ val enabled: Boolean? = null,
169
+
170
+ /**
171
+ * The ringtone resource name to be used when callkit is launched
172
+ * <br/>
173
+ * <br/>
174
+ * <b><font color="blue">default</font>: system</b>
175
+ */
176
+ val ringtoneSoundName: String? = null
177
+ )
178
+
179
+ /**
180
+ * This class defines the voip notification strategy per call.
181
+ *
182
+ * Specify the voip handling strategy.
183
+ * <br/>
184
+ * This allows you to disable or leave the plugin behaviour for handling the voip
185
+ * notifications.
186
+ * <br/>
187
+ * <br/>
188
+ * <b><font color="blue">default</font>: VoipHandlingStrategy.AUTOMATIC </b>
189
+ */
190
+ enum class VoipHandlingStrategy {
191
+ Automatic,
192
+ Disabled
193
+ }
194
+
195
+ /**
196
+ * A region where your integration will run
197
+ *
198
+ * This variable defines the region where you will be europe, india or us.
199
+ */
200
+ data class Region (
201
+ /**
202
+ * name of the region
203
+ */
204
+ val name: String
205
+ )
206
+
207
+ /**
208
+ * Define the tools to use
209
+ */
210
+ data class Tools (
211
+ /**
212
+ * Set to enable the chat feature
213
+ * <br/>
214
+ * <br/>
215
+ * <b><font color="blue">default</font>: no chat</b>
216
+ */
217
+ val chat: ChatToolConfiguration? = null,
218
+
219
+ /**
220
+ * Set to true to enable the feedback request after a call ends.
221
+ * <br/>
222
+ * <br/>
223
+ * <b><font color="blue">default</font>: false</b>
224
+ */
225
+ val feedback: Boolean? = null,
226
+
227
+ /**
228
+ * Set to true to enable the file sharing feature
229
+ * <br/>
230
+ * <br/>
231
+ * <b><font color="blue">default</font>: false</b>
232
+ */
233
+ val fileShare: Boolean? = null,
234
+
235
+ /**
236
+ * Set to enable the screen sharing feature
237
+ * <br/>
238
+ * <br/>
239
+ * <b><font color="blue">default</font>: no screen share</b>
240
+ */
241
+ val screenShare: ScreenShareToolConfiguration? = null,
242
+
243
+ /**
244
+ * Set to true to enable the whiteboard feature
245
+ * <br/>
246
+ * <br/>
247
+ * <b><font color="blue">default</font>: false</b>
248
+ */
249
+ val whiteboard: Boolean? = null
250
+ )
251
+
252
+ /**
253
+ * Chat tool configuration
254
+ *
255
+ * Set to enable the chat feature
256
+ * <br/>
257
+ * <br/>
258
+ * <b><font color="blue">default</font>: no chat</b>
259
+ */
260
+ data class ChatToolConfiguration (
261
+ /**
262
+ * Defining this object will enable an option to start an audio call from chat UI
263
+ */
264
+ val audioCallOption: AudioCallOptions? = null,
265
+
266
+ /**
267
+ * Defining this object will enable an option to start an audio&video call from chat UI
268
+ */
269
+ val videoCallOption: CallOptions? = null
270
+ )
271
+
272
+ /**
273
+ * Audio call options used for chat
274
+ *
275
+ * Defining this object will enable an option to start an audio call from chat UI
276
+ */
277
+ data class AudioCallOptions (
278
+ /**
279
+ * May have three different values, NONE, AUTOMATIC, MANUAL
280
+ * <br/>
281
+ * <br/>
282
+ * <b><font color="blue">default</font>: none</b>
283
+ */
284
+ val recordingType: RecordingType? = null,
285
+
286
+ /**
287
+ * Type of audioCall to launch when an option of the chat is tapped.
288
+ */
289
+ val type: AudioCallType
290
+ )
291
+
292
+ /**
293
+ * This class defines the types of audio calls supported.
294
+ *
295
+ * Type of audioCall to launch when an option of the chat is tapped.
296
+ */
297
+ enum class AudioCallType {
298
+ Audio,
299
+ AudioUpgradable
300
+ }
301
+
302
+ /**
303
+ * Options available for a call
304
+ *
305
+ * Defining this object will enable an option to start an audio&video call from chat UI
306
+ */
307
+ data class CallOptions (
308
+ /**
309
+ * May have three different values, NONE, AUTOMATIC, MANUAL
310
+ * <br/>
311
+ * <br/>
312
+ * <b><font color="blue">default</font>: none</b>
313
+ */
314
+ val recordingType: RecordingType? = null
315
+ )
316
+
317
+ /**
318
+ * Screen Share tool configuration
319
+ *
320
+ * Set to enable the screen sharing feature
321
+ * <br/>
322
+ * <br/>
323
+ * <b><font color="blue">default</font>: no screen share</b>
324
+ */
325
+ data class ScreenShareToolConfiguration (
326
+ /**
327
+ * Set to true to enable the in app screen share
328
+ * <br/>
329
+ * <br/>
330
+ * <b><font color="blue">default</font>: false</b>
331
+ */
332
+ val inApp: Boolean? = null,
333
+
334
+ /**
335
+ * Set to true to enable the whole device screen share
336
+ * <br/>
337
+ * <br/>
338
+ * <b><font color="blue">default</font>: false</b>
339
+ */
340
+ val wholeDevice: Boolean? = null
341
+ )
342
+
343
+ /**
344
+ * Session
345
+ */
346
+ data class Session (
347
+ /**
348
+ * The user id you want to connect
349
+ */
350
+ val userID: String
351
+ )
352
+
353
+ /**
354
+ * This is used to define the user details in the call/chat UI
355
+ */
356
+ data class UserDetails (
357
+ /**
358
+ * Email of the user
359
+ */
360
+ val email: String? = null,
361
+
362
+ /**
363
+ * First name of the user
364
+ */
365
+ val firstName: String? = null,
366
+
367
+ /**
368
+ * Last name of the user
369
+ */
370
+ val lastName: String? = null,
371
+
372
+ /**
373
+ * Nickname for the user
374
+ */
375
+ val nickName: String? = null,
376
+
377
+ /**
378
+ * Image url to use as placeholder for the user.
379
+ */
380
+ val profileImageURL: String? = null,
381
+
382
+ /**
383
+ * User identifier
384
+ */
385
+ val userID: String
386
+ )
387
+
388
+ /**
389
+ * This is used to display the user details in the call/chat UI
390
+ */
391
+ data class UserDetailsFormat (
392
+ /**
393
+ * Format to be used when displaying an android notification
394
+ * <br/>
395
+ * <br/>
396
+ * <b><font color="blue">default</font>: equals to UserDetailsFormatter.default</b>
397
+ */
398
+ val androidNotification: String? = null,
399
+
400
+ /**
401
+ * Format to be used to display a user details on the call/chat UI
402
+ * <br/>
403
+ * <br/>
404
+ * <b><font color="blue">default</font>: ${userAlias}</b>
405
+ */
406
+ val default: String
407
+ )
@@ -0,0 +1,16 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge
5
+
6
+ import com.bandyer.android_sdk.client.AccessTokenProvider
7
+ import com.bandyer.android_sdk.client.Completion
8
+
9
+ internal class SDKAccessTokenProviderProxy(val tokenProvider: CrossPlatformAccessTokenProvider) : AccessTokenProvider {
10
+ override fun provideAccessToken(userId: String, completion: Completion<String>) {
11
+ tokenProvider.provideAccessToken(userId) {
12
+ if (it.isSuccess) completion.success(it.getOrThrow())
13
+ else completion.error(it.exceptionOrNull() ?: Throwable("connection error"))
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,21 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge
5
+
6
+ import com.kaleyra.video_hybrid_native_bridge.configurator.CachedSDKConfigurator
7
+ import com.kaleyra.video_hybrid_native_bridge.connector.CachedUserConnector
8
+ import com.kaleyra.video_hybrid_native_bridge.events.EventsEmitter
9
+ import com.kaleyra.video_hybrid_native_bridge.ui.UserInterfacePresenter
10
+ import com.kaleyra.video_hybrid_native_bridge.user_details.CachedUserDetails
11
+
12
+ interface VideoHybridBridge : CachedUserConnector, UserInterfacePresenter, CachedUserDetails, CachedSDKConfigurator {
13
+
14
+ val contextContainer: ContextContainer
15
+
16
+ val tokenProvider: CrossPlatformAccessTokenProvider
17
+
18
+ val eventsEmitter: EventsEmitter
19
+ fun verifyCurrentCall(verify: Boolean)
20
+ fun handlePushNotificationPayload(payload: String)
21
+ }
@@ -0,0 +1,64 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge
5
+
6
+ import com.bandyer.android_sdk.client.BandyerSDK
7
+ import com.bandyer.android_sdk.client.BandyerSDKInstance
8
+ import com.kaleyra.video_hybrid_native_bridge.configurator.CachedSDKConfigurator
9
+ import com.kaleyra.video_hybrid_native_bridge.configurator.VideoSDKConfigurator
10
+ import com.kaleyra.video_hybrid_native_bridge.connector.VideoSDKCachedUserConnector
11
+ import com.kaleyra.video_hybrid_native_bridge.connector.CachedUserConnector
12
+ import com.kaleyra.video_hybrid_native_bridge.events.EventsEmitter
13
+ import com.kaleyra.video_hybrid_native_bridge.events.EventsReporter
14
+ import com.kaleyra.video_hybrid_native_bridge.events.reporter.SDKEventsReporter
15
+ import com.kaleyra.video_hybrid_native_bridge.repository.VideoHybridBridgeRepository
16
+ import com.kaleyra.video_hybrid_native_bridge.ui.SDKUserInterfacePresenter
17
+ import com.kaleyra.video_hybrid_native_bridge.ui.UserInterfacePresenter
18
+ import com.kaleyra.video_hybrid_native_bridge.user_details.CachedUserDetails
19
+ import com.kaleyra.video_hybrid_native_bridge.user_details.SDKCachedUserDetails
20
+ import kotlinx.coroutines.CoroutineScope
21
+ import kotlinx.coroutines.asCoroutineDispatcher
22
+ import java.util.concurrent.Executors
23
+
24
+ class VideoSDKHybridBridge(
25
+ override val contextContainer: ContextContainer,
26
+ override val tokenProvider: CrossPlatformAccessTokenProvider,
27
+ override val eventsEmitter: EventsEmitter,
28
+ private val sdk: BandyerSDKInstance = BandyerSDK.getInstance(),
29
+ private val presenter: UserInterfacePresenter = SDKUserInterfacePresenter(sdk, contextContainer),
30
+ private val backgroundScope: CoroutineScope = CoroutineScope(Executors.newSingleThreadExecutor().asCoroutineDispatcher()),
31
+ private val eventsReporter: EventsReporter = SDKEventsReporter.create(sdk, eventsEmitter, backgroundScope),
32
+ private val repository: VideoHybridBridgeRepository = VideoHybridBridgeRepository.getInstance(contextContainer.context.applicationContext),
33
+ private val connector: CachedUserConnector = VideoSDKCachedUserConnector(sdk, repository, tokenProvider, eventsReporter, backgroundScope),
34
+ private val userDetails: CachedUserDetails = SDKCachedUserDetails(sdk, contextContainer, repository, backgroundScope),
35
+ private val createCallOptionsProxy: CreateCallOptionsProxy = CreateCallOptionsProxy(),
36
+ private val configurator: CachedSDKConfigurator = VideoSDKConfigurator(sdk, createCallOptionsProxy, repository, backgroundScope),
37
+ ) : VideoHybridBridge,
38
+ CachedUserConnector by connector,
39
+ UserInterfacePresenter by presenter,
40
+ CachedUserDetails by userDetails,
41
+ CachedSDKConfigurator by configurator {
42
+
43
+ override fun handlePushNotificationPayload(payload: String) = sdk.handleNotification(payload.replace("\\", ""))
44
+
45
+ override fun reset() {
46
+ configurator.reset()
47
+ clearUserCache()
48
+ }
49
+
50
+ override fun clearUserCache() {
51
+ connector.clearUserCache()
52
+ removeUserDetails()
53
+ }
54
+
55
+ override fun startCall(callOptions: CreateCallOptions) {
56
+ createCallOptionsProxy.createCallOptions = callOptions
57
+ presenter.startCall(callOptions)
58
+ }
59
+
60
+ override fun verifyCurrentCall(verify: Boolean) {
61
+ val ongoingCall = sdk.callModule?.ongoingCall ?: return
62
+ sdk.callModule?.setVerified(ongoingCall, verify)
63
+ }
64
+ }
@@ -0,0 +1,15 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.configurator
5
+
6
+ import com.kaleyra.video_hybrid_native_bridge.KaleyraVideoConfiguration
7
+
8
+ interface CachedSDKConfigurator {
9
+
10
+ val lastConfiguration: KaleyraVideoConfiguration?
11
+
12
+ fun configureBridge(configuration: KaleyraVideoConfiguration)
13
+
14
+ fun reset()
15
+ }
@@ -0,0 +1,46 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.configurator
5
+
6
+ import com.bandyer.android_sdk.client.BandyerSDKInstance
7
+ import com.kaleyra.video_hybrid_native_bridge.KaleyraVideoConfiguration
8
+ import com.kaleyra.video_hybrid_native_bridge.CreateCallOptionsProxy
9
+ import com.kaleyra.video_hybrid_native_bridge.extensions.toSDK
10
+ import com.kaleyra.video_hybrid_native_bridge.repository.ConfigurationEntity
11
+ import com.kaleyra.video_hybrid_native_bridge.repository.VideoHybridBridgeRepository
12
+ import kotlinx.coroutines.CoroutineScope
13
+ import kotlinx.coroutines.launch
14
+
15
+ internal class VideoSDKConfigurator(
16
+ private val sdk: BandyerSDKInstance,
17
+ private val createCallOptionsProxy: CreateCallOptionsProxy,
18
+ private val repository: VideoHybridBridgeRepository,
19
+ private val scope: CoroutineScope
20
+ ) : CachedSDKConfigurator {
21
+
22
+ override var lastConfiguration: KaleyraVideoConfiguration? = null
23
+
24
+ override fun configureBridge(configuration: KaleyraVideoConfiguration) {
25
+ scope.launch {
26
+ repository.configurationDao().insert(ConfigurationEntity(configuration))
27
+ sdk.configure(configuration.toSDK(createCallOptionsProxy))
28
+ lastConfiguration = configuration
29
+ }
30
+ }
31
+
32
+ override fun reset() {
33
+ scope.launch {
34
+ repository.clearAllTables()
35
+ sdk.reset()
36
+ lastConfiguration = null
37
+ }
38
+ }
39
+
40
+ init {
41
+ scope.launch {
42
+ lastConfiguration = repository.configurationDao().configuration?.plugin
43
+ }
44
+ }
45
+
46
+ }
@@ -0,0 +1,15 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.connector
5
+
6
+ interface CachedUserConnector {
7
+
8
+ val lastConnectedUserId: String?
9
+
10
+ fun connect(userID: String)
11
+
12
+ fun disconnect()
13
+
14
+ fun clearUserCache()
15
+ }
@@ -0,0 +1,60 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.connector
5
+
6
+ import androidx.annotation.VisibleForTesting
7
+ import com.bandyer.android_sdk.client.BandyerSDKInstance
8
+ import com.bandyer.android_sdk.client.Session
9
+ import com.kaleyra.video_hybrid_native_bridge.CrossPlatformAccessTokenProvider
10
+ import com.kaleyra.video_hybrid_native_bridge.SDKAccessTokenProviderProxy
11
+ import com.kaleyra.video_hybrid_native_bridge.events.EventsReporter
12
+ import com.kaleyra.video_hybrid_native_bridge.repository.ConnectedUserEntity
13
+ import com.kaleyra.video_hybrid_native_bridge.repository.VideoHybridBridgeRepository
14
+ import kotlinx.coroutines.CoroutineScope
15
+ import kotlinx.coroutines.launch
16
+
17
+ internal class VideoSDKCachedUserConnector(
18
+ private val sdk: BandyerSDKInstance,
19
+ private val repository: VideoHybridBridgeRepository,
20
+ private val tokenProvider: CrossPlatformAccessTokenProvider,
21
+ private val eventsReporter: EventsReporter,
22
+ private val scope: CoroutineScope
23
+ ) : CachedUserConnector {
24
+
25
+ override var lastConnectedUserId: String? = null
26
+
27
+ @VisibleForTesting
28
+ internal val accessTokenProviderProxy = SDKAccessTokenProviderProxy(tokenProvider)
29
+
30
+ override fun connect(userID: String) {
31
+ scope.launch {
32
+ repository.connectedUserDao().insert(ConnectedUserEntity(userID))
33
+ eventsReporter.start()
34
+ sdk.connect(Session(userID, accessTokenProviderProxy))
35
+ lastConnectedUserId = userID
36
+ }
37
+ }
38
+
39
+ override fun disconnect() {
40
+ scope.launch {
41
+ eventsReporter.stop()
42
+ sdk.disconnect()
43
+ }
44
+ }
45
+
46
+ override fun clearUserCache() {
47
+ scope.launch {
48
+ repository.connectedUserDao().clear()
49
+ disconnect()
50
+ sdk.disconnect(true)
51
+ lastConnectedUserId = null
52
+ }
53
+ }
54
+
55
+ init {
56
+ scope.launch {
57
+ lastConnectedUserId = repository.connectedUserDao().user?.user
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,29 @@
1
+ // To parse the JSON, install kotlin's serialization plugin and do:
2
+ //
3
+ // val json = Json { allowStructuredMapKeys = true }
4
+ // val events = json.parse(Events.serializer(), jsonString)
5
+
6
+ package com.kaleyra.video_hybrid_native_bridge.events
7
+
8
+ import kotlinx.serialization.*
9
+ import kotlinx.serialization.json.*
10
+ import kotlinx.serialization.descriptors.*
11
+ import kotlinx.serialization.encoding.*
12
+
13
+ /**
14
+ * This enum defines all the events that may be handled
15
+ * <br/>
16
+ * <br/>
17
+ * You can listen to these events via [[BandyerPlugin.on]]
18
+ */
19
+ @Serializable
20
+ enum class Events(val value: String) {
21
+ @SerialName("accessTokenRequest") AccessTokenRequest("accessTokenRequest"),
22
+ @SerialName("callError") CallError("callError"),
23
+ @SerialName("callModuleStatusChanged") CallModuleStatusChanged("callModuleStatusChanged"),
24
+ @SerialName("chatError") ChatError("chatError"),
25
+ @SerialName("chatModuleStatusChanged") ChatModuleStatusChanged("chatModuleStatusChanged"),
26
+ @SerialName("iOSVoipPushTokenInvalidated") IOSVoipPushTokenInvalidated("iOSVoipPushTokenInvalidated"),
27
+ @SerialName("iOSVoipPushTokenUpdated") IOSVoipPushTokenUpdated("iOSVoipPushTokenUpdated"),
28
+ @SerialName("setupError") SetupError("setupError");
29
+ }
@@ -0,0 +1,8 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.events
5
+
6
+ interface EventsEmitter {
7
+ fun sendEvent(event: Events, args: Any?)
8
+ }
@@ -0,0 +1,9 @@
1
+ // Copyright © 2018-2023 Kaleyra S.p.a. All Rights Reserved.
2
+ // See LICENSE for licensing information
3
+
4
+ package com.kaleyra.video_hybrid_native_bridge.events
5
+
6
+ interface EventsReporter {
7
+ fun start()
8
+ fun stop()
9
+ }