mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-04-17 05:49:59 +00:00
implemented resuming session
This commit is contained in:
@@ -21,6 +21,9 @@
|
||||
self = [super init];
|
||||
_config = config;
|
||||
_renderView = view;
|
||||
_config.riKey = [Utils randomBytes:16];
|
||||
_config.riKeyId = arc4random();
|
||||
_config.bitRate = 10000;
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -30,23 +33,43 @@
|
||||
NSString* uniqueId = [CryptoManager getUniqueID];
|
||||
NSData* cert = [CryptoManager readCertFromFile];
|
||||
|
||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_config.host uniqueId:uniqueId deviceName:@"roth" cert:cert];
|
||||
NSData* riKey = [Utils randomBytes:16];
|
||||
int riKeyId = arc4random();
|
||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_config.host
|
||||
uniqueId:uniqueId
|
||||
deviceName:@"roth"
|
||||
cert:cert];
|
||||
|
||||
NSData* launchResp = [hMan executeRequestSynchronously:[hMan newLaunchRequest:@"67339056" width:_config.width height:_config.height refreshRate:_config.frameRate rikey:[Utils bytesToHex:riKey] rikeyid:riKeyId]];
|
||||
[HttpManager getStringFromXML:launchResp tag:@"gamesession"];
|
||||
NSData* serverInfoResp = [hMan executeRequestSynchronously:[hMan newServerInfoRequest]];
|
||||
if (![[HttpManager getStringFromXML:serverInfoResp tag:@"currentgame"] isEqualToString:@"0"]) {
|
||||
// App already running, resume it
|
||||
[self resumeApp:hMan];
|
||||
} else {
|
||||
// Start app
|
||||
[self launchApp:hMan];
|
||||
}
|
||||
|
||||
VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:_renderView];
|
||||
|
||||
_config.bitRate = 10000;
|
||||
_config.riKey = riKey;
|
||||
_config.riKeyId = riKeyId;
|
||||
|
||||
Connection* conn = [[Connection alloc] initWithConfig:_config renderer:renderer];
|
||||
|
||||
NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
|
||||
[opQueue addOperation:conn];
|
||||
}
|
||||
|
||||
- (void) launchApp:(HttpManager*)hMan {
|
||||
NSData* launchResp = [hMan executeRequestSynchronously:
|
||||
[hMan newLaunchRequest:@"67339056"
|
||||
width:_config.width
|
||||
height:_config.height
|
||||
refreshRate:_config.frameRate
|
||||
rikey:[Utils bytesToHex:_config.riKey]
|
||||
rikeyid:_config.riKeyId]];
|
||||
[HttpManager getStringFromXML:launchResp tag:@"gamesession"];
|
||||
}
|
||||
|
||||
- (void) resumeApp:(HttpManager*)hMan {
|
||||
NSData* resumeResp = [hMan executeRequestSynchronously:
|
||||
[hMan newResumeRequestWithRiKey:[Utils bytesToHex:_config.riKey]
|
||||
riKeyId:_config.riKeyId]];
|
||||
[HttpManager getStringFromXML:resumeResp tag:@"gamesession"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user