@@ -25,15 +25,18 @@ extension ChatClient {
2525
2626 var webSocketClientBuilder : ( @Sendable (
2727 _ sessionConfiguration: URLSessionConfiguration ,
28- _ requestEncoder: RequestEncoder ,
2928 _ eventDecoder: AnyEventDecoder ,
30- _ notificationCenter: EventNotificationCenter
29+ _ notificationCenter: PersistentEventNotificationCenter
3130 ) -> WebSocketClient ) ? = {
32- WebSocketClient (
31+ let wsEnvironment = WebSocketClient . Environment ( eventBatchingPeriod: 0.5 )
32+ return WebSocketClient (
3333 sessionConfiguration: $0,
34- requestEncoder: $1,
35- eventDecoder: $2,
36- eventNotificationCenter: $3
34+ eventDecoder: $1,
35+ eventNotificationCenter: $2,
36+ webSocketClientType: . coordinator,
37+ environment: wsEnvironment,
38+ connectRequest: nil ,
39+ healthCheckBeforeConnected: true
3740 )
3841 }
3942
@@ -57,7 +60,7 @@ extension ChatClient {
5760
5861 var eventDecoderBuilder : @Sendable ( ) -> EventDecoder = { EventDecoder ( ) }
5962
60- var notificationCenterBuilder : @Sendable ( _ database: DatabaseContainer , _ manualEventHandler: ManualEventHandler ? ) -> EventNotificationCenter = { EventNotificationCenter ( database: $0, manualEventHandler: $1) }
63+ var notificationCenterBuilder : @Sendable ( _ database: DatabaseContainer , _ manualEventHandler: ManualEventHandler ? ) -> PersistentEventNotificationCenter = { PersistentEventNotificationCenter ( database: $0, manualEventHandler: $1) }
6164
6265 var internetConnection : @Sendable ( _ center: NotificationCenter , _ monitor: InternetConnectionMonitor ) -> InternetConnection = {
6366 InternetConnection ( notificationCenter: $0, monitor: $1)
@@ -76,16 +79,18 @@ extension ChatClient {
7679 var connectionRepositoryBuilder : @Sendable (
7780 _ isClientInActiveMode: Bool ,
7881 _ syncRepository: SyncRepository ,
82+ _ webSocketEncoder: RequestEncoder ? ,
7983 _ webSocketClient: WebSocketClient ? ,
8084 _ apiClient: APIClient ,
81- _ timerType: Timer . Type
85+ _ timerType: TimerScheduling . Type
8286 ) -> ConnectionRepository = {
8387 ConnectionRepository (
8488 isClientInActiveMode: $0,
8589 syncRepository: $1,
86- webSocketClient: $2,
87- apiClient: $3,
88- timerType: $4
90+ webSocketEncoder: $2,
91+ webSocketClient: $3,
92+ apiClient: $4,
93+ timerType: $5
8994 )
9095 }
9196
@@ -103,27 +108,25 @@ extension ChatClient {
103108 }
104109 }
105110
106- var timerType : Timer . Type = DefaultTimer . self
111+ var timerType : TimerScheduling . Type = DefaultTimer . self
107112
108113 var tokenExpirationRetryStrategy : RetryStrategy = DefaultRetryStrategy ( )
109114
110115 var connectionRecoveryHandlerBuilder : @Sendable (
111116 _ webSocketClient: WebSocketClient ,
112117 _ eventNotificationCenter: EventNotificationCenter ,
113- _ syncRepository: SyncRepository ,
114118 _ backgroundTaskScheduler: BackgroundTaskScheduler ? ,
115119 _ internetConnection: InternetConnection ,
116120 _ keepConnectionAliveInBackground: Bool
117121 ) -> ConnectionRecoveryHandler = {
118122 DefaultConnectionRecoveryHandler (
119123 webSocketClient: $0,
120124 eventNotificationCenter: $1,
121- syncRepository: $2,
122- backgroundTaskScheduler: $3,
123- internetConnection: $4,
125+ backgroundTaskScheduler: $2,
126+ internetConnection: $3,
124127 reconnectionStrategy: DefaultRetryStrategy ( ) ,
125128 reconnectionTimerType: DefaultTimer . self,
126- keepConnectionAliveInBackground: $5
129+ keepConnectionAliveInBackground: $4
127130 )
128131 }
129132
@@ -132,7 +135,7 @@ extension ChatClient {
132135 _ databaseContainer: DatabaseContainer ,
133136 _ connectionRepository: ConnectionRepository ,
134137 _ tokenExpirationRetryStrategy: RetryStrategy ,
135- _ timerType: Timer . Type
138+ _ timerType: TimerScheduling . Type
136139 ) -> AuthenticationRepository = {
137140 AuthenticationRepository (
138141 apiClient: $0,
0 commit comments