Skip to content

Commit 1b84cb0

Browse files
author
garenwang
committed
fix:quic修复
1 parent b1d06a7 commit 1b84cb0

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

QCloudQuic/Classes/QCloudBase/TquicConnection.mm

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
private:
3535
int first_time_;
3636
int64_t totolSentBytes;
37+
bool isComplete;
3738

3839
public:
3940
TnetAsyncDelegate() {
@@ -174,26 +175,29 @@ void OnConnectionClose(int error_code, const char* error_detail) override{
174175
error = [[NSError alloc] initWithDomain:NSURLErrorDomain code:error_code userInfo:@{NSLocalizedDescriptionKey:[NSString stringWithFormat:@"%s",error_detail]}];
175176

176177
}
177-
if (this->didCompleteWithError_ !=nullptr) {
178-
this->didCompleteWithError_(error);
178+
if (!isComplete) {
179+
isComplete = YES;
180+
if (this->didCompleteWithError_ !=nullptr) {
181+
this->didCompleteWithError_(error);
182+
}
179183
}
180-
181184
}
182185

183186
// This request has received all the data and finished.
184187
void OnRequestFinish(int stream_error) override{
185-
// request_sp->CloseConnection();
186-
// NSError *error = nil;
187-
// if (stream_error != 0) {
188-
// error = [[NSError alloc] initWithDomain:NSURLErrorDomain code:stream_error userInfo:nil];
189-
// }
190-
//
191-
// NSLog(@"Tquic OnRequestCompleted with error: %@", error);
192-
// if (this->didCompleteWithError_ != nullptr) {
193-
// this->didCompleteWithError_(error);
194-
// }
195-
196-
188+
request_sp->CloseConnection();
189+
NSError *error = nil;
190+
if (stream_error != 0) {
191+
error = [[NSError alloc] initWithDomain:NSURLErrorDomain code:stream_error userInfo:nil];
192+
}
193+
194+
NSLog(@"Tquic OnRequestCompleted with error: %@", error);
195+
if (!isComplete) {
196+
isComplete = YES;
197+
if (this->didCompleteWithError_ != nullptr) {
198+
this->didCompleteWithError_(error);
199+
}
200+
}
197201
}
198202
};
199203

0 commit comments

Comments
 (0)