mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-01 23:35:59 +00:00
Consolidate launch and resume handling for Sunshine
This commit is contained in:
parent
dbb3087078
commit
a04e1ebb3b
@ -26,8 +26,7 @@
|
|||||||
- (NSURLRequest*) newServerInfoRequest:(bool)fastFail;
|
- (NSURLRequest*) newServerInfoRequest:(bool)fastFail;
|
||||||
- (NSURLRequest*) newHttpServerInfoRequest:(bool)fastFail;
|
- (NSURLRequest*) newHttpServerInfoRequest:(bool)fastFail;
|
||||||
- (NSURLRequest*) newHttpServerInfoRequest;
|
- (NSURLRequest*) newHttpServerInfoRequest;
|
||||||
- (NSURLRequest*) newLaunchRequest:(StreamConfiguration*)config;
|
- (NSURLRequest*) newLaunchOrResumeRequest:(NSString*)verb config:(StreamConfiguration*)config;
|
||||||
- (NSURLRequest*) newResumeRequest:(StreamConfiguration*)config;
|
|
||||||
- (NSURLRequest*) newQuitAppRequest;
|
- (NSURLRequest*) newQuitAppRequest;
|
||||||
- (NSURLRequest*) newAppAssetRequestWithAppId:(NSString*)appId;
|
- (NSURLRequest*) newAppAssetRequestWithAppId:(NSString*)appId;
|
||||||
- (void) executeRequestSynchronously:(HttpRequest*)request;
|
- (void) executeRequestSynchronously:(HttpRequest*)request;
|
||||||
|
@ -264,7 +264,7 @@
|
|||||||
return [self newHttpServerInfoRequest:false];
|
return [self newHttpServerInfoRequest:false];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSURLRequest*) newLaunchRequest:(StreamConfiguration*)config {
|
- (NSURLRequest*) newLaunchOrResumeRequest:(NSString*)verb config:(StreamConfiguration*)config {
|
||||||
if (![self ensureHttpsUrlPopulated:NO]) {
|
if (![self ensureHttpsUrlPopulated:NO]) {
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
@ -276,8 +276,8 @@
|
|||||||
// indicated by a negative version in the last field.
|
// indicated by a negative version in the last field.
|
||||||
int fps = (config.frameRate > 60 && ![config.appVersion containsString:@".-"]) ? 0 : config.frameRate;
|
int fps = (config.frameRate > 60 && ![config.appVersion containsString:@".-"]) ? 0 : config.frameRate;
|
||||||
|
|
||||||
NSString* urlString = [NSString stringWithFormat:@"%@/launch?uniqueid=%@&appid=%@&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%@&rikeyid=%d%@&localAudioPlayMode=%d&surroundAudioInfo=%d&remoteControllersBitmap=%d&gcmap=%d",
|
NSString* urlString = [NSString stringWithFormat:@"%@/%@?uniqueid=%@&appid=%@&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%@&rikeyid=%d%@&localAudioPlayMode=%d&surroundAudioInfo=%d&remoteControllersBitmap=%d&gcmap=%d",
|
||||||
_baseHTTPSURL, _uniqueId,
|
_baseHTTPSURL, verb, _uniqueId,
|
||||||
config.appID,
|
config.appID,
|
||||||
config.width, config.height, fps,
|
config.width, config.height, fps,
|
||||||
config.optimizeGameSettings ? 1 : 0,
|
config.optimizeGameSettings ? 1 : 0,
|
||||||
@ -291,20 +291,6 @@
|
|||||||
return [self createRequestFromString:urlString timeout:LONG_TIMEOUT_SEC];
|
return [self createRequestFromString:urlString timeout:LONG_TIMEOUT_SEC];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSURLRequest*) newResumeRequest:(StreamConfiguration*)config {
|
|
||||||
if (![self ensureHttpsUrlPopulated:NO]) {
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSString* urlString = [NSString stringWithFormat:@"%@/resume?uniqueid=%@&rikey=%@&rikeyid=%d&surroundAudioInfo=%d",
|
|
||||||
_baseHTTPSURL, _uniqueId,
|
|
||||||
[Utils bytesToHex:config.riKey], config.riKeyId,
|
|
||||||
SURROUNDAUDIOINFO_FROM_AUDIO_CONFIGURATION(config.audioConfiguration)];
|
|
||||||
Log(LOG_I, @"Requesting: %@", urlString);
|
|
||||||
// This blocks while the app is resuming
|
|
||||||
return [self createRequestFromString:urlString timeout:LONG_TIMEOUT_SEC];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSURLRequest*) newQuitAppRequest {
|
- (NSURLRequest*) newQuitAppRequest {
|
||||||
if (![self ensureHttpsUrlPopulated:NO]) {
|
if (![self ensureHttpsUrlPopulated:NO]) {
|
||||||
return nil;
|
return nil;
|
||||||
|
@ -113,7 +113,7 @@
|
|||||||
|
|
||||||
- (BOOL) launchApp:(HttpManager*)hMan receiveSessionUrl:(NSString**)sessionUrl {
|
- (BOOL) launchApp:(HttpManager*)hMan receiveSessionUrl:(NSString**)sessionUrl {
|
||||||
HttpResponse* launchResp = [[HttpResponse alloc] init];
|
HttpResponse* launchResp = [[HttpResponse alloc] init];
|
||||||
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:launchResp withUrlRequest:[hMan newLaunchRequest:_config]]];
|
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:launchResp withUrlRequest:[hMan newLaunchOrResumeRequest:@"launch" config:_config]]];
|
||||||
NSString *gameSession = [launchResp getStringTag:@"gamesession"];
|
NSString *gameSession = [launchResp getStringTag:@"gamesession"];
|
||||||
if (![launchResp isStatusOk]) {
|
if (![launchResp isStatusOk]) {
|
||||||
[_callbacks launchFailed:launchResp.statusMessage];
|
[_callbacks launchFailed:launchResp.statusMessage];
|
||||||
@ -131,7 +131,7 @@
|
|||||||
|
|
||||||
- (BOOL) resumeApp:(HttpManager*)hMan receiveSessionUrl:(NSString**)sessionUrl {
|
- (BOOL) resumeApp:(HttpManager*)hMan receiveSessionUrl:(NSString**)sessionUrl {
|
||||||
HttpResponse* resumeResp = [[HttpResponse alloc] init];
|
HttpResponse* resumeResp = [[HttpResponse alloc] init];
|
||||||
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:resumeResp withUrlRequest:[hMan newResumeRequest:_config]]];
|
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:resumeResp withUrlRequest:[hMan newLaunchOrResumeRequest:@"resume" config:_config]]];
|
||||||
NSString* resume = [resumeResp getStringTag:@"resume"];
|
NSString* resume = [resumeResp getStringTag:@"resume"];
|
||||||
if (![resumeResp isStatusOk]) {
|
if (![resumeResp isStatusOk]) {
|
||||||
[_callbacks launchFailed:resumeResp.statusMessage];
|
[_callbacks launchFailed:resumeResp.statusMessage];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user