@@ -103,9 +103,8 @@ protected virtual CookieContainer CreateCookieContainer(IBrowserProfile browserP
103
103
return cc ;
104
104
}
105
105
//protected virtual Extract()
106
- public async Task ConnectAsync ( string input , IBrowserProfile browserProfile )
106
+ private async Task ConnectInternalAsync ( string input , IBrowserProfile browserProfile )
107
107
{
108
- BeforeConnecting ( ) ;
109
108
if ( _ws != null )
110
109
{
111
110
throw new InvalidOperationException ( "" ) ;
@@ -146,17 +145,24 @@ public async Task ConnectAsync(string input, IBrowserProfile browserProfile)
146
145
_startAt = movieContext2 . StartedAt . DateTime ;
147
146
_500msTimer . Enabled = true ;
148
147
149
- var chats = await GetChats ( movieContext2 ) ;
150
- foreach ( var item in chats )
148
+ var ( chats , raw ) = await GetChats ( movieContext2 ) ;
149
+ try
151
150
{
152
- var comment = Tools . Parse ( item ) ;
153
- var commentData = Tools . CreateCommentData ( comment , _startAt , _siteOptions ) ;
154
- var messageContext = CreateMessageContext ( comment , commentData , true ) ;
155
- if ( messageContext != null )
151
+ foreach ( var item in chats )
156
152
{
157
- MessageReceived ? . Invoke ( this , messageContext ) ;
153
+ var comment = Tools . Parse ( item ) ;
154
+ var commentData = Tools . CreateCommentData ( comment , _startAt , _siteOptions ) ;
155
+ var messageContext = CreateMessageContext ( comment , commentData , true ) ;
156
+ if ( messageContext != null )
157
+ {
158
+ MessageReceived ? . Invoke ( this , messageContext ) ;
159
+ }
158
160
}
159
161
}
162
+ catch ( Exception ex )
163
+ {
164
+ _logger . LogException ( ex , "" , "raw=" + raw ) ;
165
+ }
160
166
foreach ( var user in _userStoreManager . GetAllUsers ( SiteType . Openrec ) )
161
167
{
162
168
if ( ! ( user is IUser2 user2 ) ) continue ;
@@ -231,7 +237,18 @@ public async Task ConnectAsync(string input, IBrowserProfile browserProfile)
231
237
goto Reconnect ;
232
238
}
233
239
}
234
- AfterDisconnected ( ) ;
240
+ }
241
+ public async Task ConnectAsync ( string input , IBrowserProfile browserProfile )
242
+ {
243
+ BeforeConnecting ( ) ;
244
+ try
245
+ {
246
+ await ConnectInternalAsync ( input , browserProfile ) ;
247
+ }
248
+ finally
249
+ {
250
+ AfterDisconnected ( ) ;
251
+ }
235
252
}
236
253
237
254
protected virtual IBlackListProvider CreateBlacklistProvider ( )
@@ -244,7 +261,7 @@ protected virtual IOpenrecWebsocket CreateOpenrecWebsocket()
244
261
return new OpenrecWebsocket ( _logger ) ;
245
262
}
246
263
247
- protected virtual async Task < Low . Chats . RootObject [ ] > GetChats ( MovieInfo movieContext2 )
264
+ protected virtual async Task < ( Low . Chats . RootObject [ ] , string raw ) > GetChats ( MovieInfo movieContext2 )
248
265
{
249
266
return await API . GetChats ( _dataSource , movieContext2 . Id , DateTime . Now , _cc ) ;
250
267
}
0 commit comments