mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-23 12:44:19 +00:00
implemented resuming session
This commit is contained in:
parent
4c646e36c7
commit
84316166eb
@ -22,6 +22,7 @@
|
|||||||
- (NSURLRequest*) newAppListRequest;
|
- (NSURLRequest*) newAppListRequest;
|
||||||
- (NSURLRequest*) newServerInfoRequest;
|
- (NSURLRequest*) newServerInfoRequest;
|
||||||
- (NSURLRequest*) newLaunchRequest:(NSString*)appId width:(int)width height:(int)height refreshRate:(int)refreshRate rikey:(NSString*)rikey rikeyid:(int)rikeyid;
|
- (NSURLRequest*) newLaunchRequest:(NSString*)appId width:(int)width height:(int)height refreshRate:(int)refreshRate rikey:(NSString*)rikey rikeyid:(int)rikeyid;
|
||||||
|
- (NSURLRequest*) newResumeRequestWithRiKey:(NSString*)riKey riKeyId:(int)riKeyId;
|
||||||
- (NSData*) executeRequestSynchronously:(NSURLRequest*)request;
|
- (NSData*) executeRequestSynchronously:(NSURLRequest*)request;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -155,6 +155,11 @@ static const NSString* PORT = @"47984";
|
|||||||
return [self createRequestFromString:urlString];
|
return [self createRequestFromString:urlString];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSURLRequest*) newResumeRequestWithRiKey:(NSString*)riKey riKeyId:(int)riKeyId {
|
||||||
|
NSString* urlString = [NSString stringWithFormat:@"%@/resume?uniqueid=%@&rikey=%@&rikeyid=%d", _baseURL, _uniqueId, riKey, riKeyId];
|
||||||
|
return [self createRequestFromString:urlString];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString*) bytesToHex:(NSData*)data {
|
- (NSString*) bytesToHex:(NSData*)data {
|
||||||
const unsigned char* bytes = [data bytes];
|
const unsigned char* bytes = [data bytes];
|
||||||
NSMutableString *hex = [[NSMutableString alloc] init];
|
NSMutableString *hex = [[NSMutableString alloc] init];
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
self = [super init];
|
self = [super init];
|
||||||
_config = config;
|
_config = config;
|
||||||
_renderView = view;
|
_renderView = view;
|
||||||
|
_config.riKey = [Utils randomBytes:16];
|
||||||
|
_config.riKeyId = arc4random();
|
||||||
|
_config.bitRate = 10000;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,23 +33,43 @@
|
|||||||
NSString* uniqueId = [CryptoManager getUniqueID];
|
NSString* uniqueId = [CryptoManager getUniqueID];
|
||||||
NSData* cert = [CryptoManager readCertFromFile];
|
NSData* cert = [CryptoManager readCertFromFile];
|
||||||
|
|
||||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_config.host uniqueId:uniqueId deviceName:@"roth" cert:cert];
|
HttpManager* hMan = [[HttpManager alloc] initWithHost:_config.host
|
||||||
NSData* riKey = [Utils randomBytes:16];
|
uniqueId:uniqueId
|
||||||
int riKeyId = arc4random();
|
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]];
|
NSData* serverInfoResp = [hMan executeRequestSynchronously:[hMan newServerInfoRequest]];
|
||||||
[HttpManager getStringFromXML:launchResp tag:@"gamesession"];
|
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];
|
VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:_renderView];
|
||||||
|
|
||||||
_config.bitRate = 10000;
|
|
||||||
_config.riKey = riKey;
|
|
||||||
_config.riKeyId = riKeyId;
|
|
||||||
|
|
||||||
Connection* conn = [[Connection alloc] initWithConfig:_config renderer:renderer];
|
Connection* conn = [[Connection alloc] initWithConfig:_config renderer:renderer];
|
||||||
|
|
||||||
NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
|
NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
|
||||||
[opQueue addOperation:conn];
|
[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
|
@end
|
||||||
|
@ -102,6 +102,9 @@
|
|||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
|
<color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
|
||||||
</view>
|
</view>
|
||||||
|
<nil key="simulatedStatusBarMetrics"/>
|
||||||
|
<nil key="simulatedTopBarMetrics"/>
|
||||||
|
<nil key="simulatedBottomBarMetrics"/>
|
||||||
</viewController>
|
</viewController>
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="pqv-jd-33O" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
<placeholder placeholderIdentifier="IBFirstResponder" id="pqv-jd-33O" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
</objects>
|
</objects>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user