Enhance the connection callback protocol to include other connection listener callbacks exposed by common. Start handling some HTTP request errors.

This commit is contained in:
Cameron Gutman
2014-10-21 14:54:10 -04:00
parent 01a2853032
commit ea24b39fbe
7 changed files with 83 additions and 27 deletions

View File

@@ -29,7 +29,9 @@
_controllerSupport = [[ControllerSupport alloc] init];
_streamMan = [[StreamManager alloc] initWithConfig:[MainFrameViewController getStreamConfiguration] renderView:self.view connectionTerminatedCallback:self];
_streamMan = [[StreamManager alloc] initWithConfig:[MainFrameViewController getStreamConfiguration]
renderView:self.view
connectionCallbacks:self];
NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
[opQueue addOperation:_streamMan];
@@ -44,7 +46,13 @@
[self performSegueWithIdentifier:@"returnToMainFrame" sender:self];
}
- (void)connectionTerminated {
- (void) connectionStarted {
printf("Connection started\n");
}
- (void)connectionTerminated:(long)errorCode {
printf("Connection terminated: %ld\n", errorCode);
UIAlertController* conTermAlert = [UIAlertController alertControllerWithTitle:@"Connection Terminated" message:@"The connection terminated unexpectedly" preferredStyle:UIAlertControllerStyleAlert];
[conTermAlert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){
[self performSegueWithIdentifier:@"returnToMainFrame" sender:self];
@@ -54,6 +62,36 @@
[_streamMan stopStream];
}
- (void) stageStarting:(char*)stageName {
printf("Starting %s\n", stageName);
}
- (void) stageComplete:(char*)stageName {
}
- (void) stageFailed:(char*)stageName withError:(long)errorCode {
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Connection Failed"
message:[NSString stringWithFormat:@"%s failed with error %ld",
stageName, errorCode]
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){
[self performSegueWithIdentifier:@"returnToMainFrame" sender:self];
}]];
[self presentViewController:alert animated:YES completion:nil];
}
- (void) launchFailed {
}
- (void) displayMessage:(char*)message {
printf("Display message: %s\n", message);
}
- (void) displayTransientMessage:(char*)message {
printf("Display transient message: %s\n", message);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];