Skip to content

Commit

Permalink
Call missing websocket completion (FLEXTool#609)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergo Beruashvili <sergo.beruashvili@daimler.com>
  • Loading branch information
2 people authored and Tim Johnsen committed May 1, 2023
1 parent 0a91922 commit c1ee614
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Classes/Network/PonyDebugger/FLEXNetworkObserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -1591,15 +1591,19 @@ typedef void (^SendMessageBlock)(
[FLEXNetworkObserver.sharedObserver
websocketTask:slf sendMessagage:message
];
completion = ^(NSError *error) {

id completionHook = ^(NSError *error) {
[FLEXNetworkObserver.sharedObserver
websocketTaskMessageSendCompletion:message
error:error
];
if (completion) {
completion(error);
}
};

((void(*)(id, SEL, id, id))objc_msgSend)(
slf, swizzledSelector, message, completion
slf, swizzledSelector, message, completionHook
);
};

Expand Down
4 changes: 3 additions & 1 deletion Example/FLEXample/MiscNetworkRequests.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ - (void)sendExampleNetworkRequests:(NSURLSession *)sessionWithDelegate {
}

- (void)sendExampleWebsocketTraffic:(NSURLSession *)sessionWithDelegate {
NSString *APIKey = @"oCdCMcMPQpbvNjUIzqtvF1d2X2okWpDQj4AwARJuAgtjhzKxVEjQU6IdCjwm";
NSString *APIKey = @"VCXCEuvhGcBDP7XhiJJUDvR1e1D3eiVjgZ9VRiaV";
NSString *wsurl = [NSString stringWithFormat:@"wss://demo.piesocket.com/v3/channel_1?api_key=%@&notify_self", APIKey];
NSURLSessionWebSocketTask *task = [sessionWithDelegate webSocketTaskWithURL:[NSURL URLWithString:wsurl]];
[task resume];
Expand All @@ -167,6 +167,8 @@ - (void)URLSession:(NSURLSession *)session webSocketTask:(NSURLSessionWebSocketT
[task sendMessage:message completionHandler:^(NSError *error) {
if (error) {
NSLog(@"Error sending WS message: %@", error.localizedDescription);
} else {
NSLog(@"WS message sent.");
}
}];
}
Expand Down

0 comments on commit c1ee614

Please # to comment.