mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 08:36:42 +00:00
Fix returning binary data for box art
This commit is contained in:
parent
9546e5fee1
commit
7392ea4ad7
20
http.cpp
20
http.cpp
@ -93,7 +93,7 @@ void MoonlightInstance::NvHTTPInit(int32_t callbackId, pp::VarArray args)
|
|||||||
PostMessage(ret);
|
PostMessage(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoonlightInstance::NvHTTPRequest(int32_t /*result*/, int32_t callbackId, std::string url)
|
void MoonlightInstance::NvHTTPRequest(int32_t /*result*/, int32_t callbackId, std::string url, bool binaryResponse)
|
||||||
{
|
{
|
||||||
char* _url = strdup(url.c_str());
|
char* _url = strdup(url.c_str());
|
||||||
PHTTP_DATA data = http_create_data();
|
PHTTP_DATA data = http_create_data();
|
||||||
@ -118,7 +118,23 @@ void MoonlightInstance::NvHTTPRequest(int32_t /*result*/, int32_t callbackId, st
|
|||||||
goto clean_data;
|
goto clean_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if (binaryResponse) {
|
||||||
|
// Response data will be returned to JS as an ArrayBuffer
|
||||||
|
|
||||||
|
pp::VarDictionary ret;
|
||||||
|
ret.Set("callbackId", pp::Var(callbackId));
|
||||||
|
ret.Set("type", pp::Var("resolve"));
|
||||||
|
|
||||||
|
// Construct an array buffer and copy the response data into it
|
||||||
|
pp::VarArrayBuffer arrBuf = pp::VarArrayBuffer(data->size);
|
||||||
|
memcpy(arrBuf.Map(), data->memory, data->size);
|
||||||
|
arrBuf.Unmap();
|
||||||
|
|
||||||
|
ret.Set("ret", arrBuf);
|
||||||
|
PostMessage(ret);
|
||||||
|
} else {
|
||||||
|
// Response data will be returned to JS as a UTF-8 string
|
||||||
|
|
||||||
pp::VarDictionary ret;
|
pp::VarDictionary ret;
|
||||||
ret.Set("callbackId", pp::Var(callbackId));
|
ret.Set("callbackId", pp::Var(callbackId));
|
||||||
ret.Set("type", pp::Var("resolve"));
|
ret.Set("type", pp::Var("resolve"));
|
||||||
|
3
main.cpp
3
main.cpp
@ -240,8 +240,9 @@ void MoonlightInstance::HandleStopStream(int32_t callbackId, pp::VarArray args)
|
|||||||
|
|
||||||
void MoonlightInstance::HandleOpenURL(int32_t callbackId, pp::VarArray args) {
|
void MoonlightInstance::HandleOpenURL(int32_t callbackId, pp::VarArray args) {
|
||||||
std::string url = args.Get(0).AsString();
|
std::string url = args.Get(0).AsString();
|
||||||
|
bool binaryResponse = args.Get(1).AsBool();
|
||||||
|
|
||||||
openHttpThread.message_loop().PostWork(m_CallbackFactory.NewCallback(&MoonlightInstance::NvHTTPRequest, callbackId, url));
|
openHttpThread.message_loop().PostWork(m_CallbackFactory.NewCallback(&MoonlightInstance::NvHTTPRequest, callbackId, url, binaryResponse));
|
||||||
|
|
||||||
PostMessage(pp::Var (url.c_str()));
|
PostMessage(pp::Var (url.c_str()));
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
|||||||
void LoadCert(const char* certStr, const char* keyStr);
|
void LoadCert(const char* certStr, const char* keyStr);
|
||||||
|
|
||||||
void NvHTTPInit(int32_t callbackId, pp::VarArray args);
|
void NvHTTPInit(int32_t callbackId, pp::VarArray args);
|
||||||
void NvHTTPRequest(int32_t, int32_t callbackId, std::string url);
|
void NvHTTPRequest(int32_t, int32_t callbackId, std::string url, bool binaryResponse);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static CONNECTION_LISTENER_CALLBACKS s_ClCallbacks;
|
static CONNECTION_LISTENER_CALLBACKS s_ClCallbacks;
|
||||||
|
@ -46,9 +46,9 @@ function NvHTTP(address, clientUid) {
|
|||||||
|
|
||||||
NvHTTP.prototype = {
|
NvHTTP.prototype = {
|
||||||
refreshServerInfo: function () {
|
refreshServerInfo: function () {
|
||||||
return sendMessage('openUrl', [ _self._baseUrlHttps + '/serverinfo?' + _self._buildUidStr()]).then(function(ret) {
|
return sendMessage('openUrl', [ _self._baseUrlHttps + '/serverinfo?' + _self._buildUidStr(), false]).then(function(ret) {
|
||||||
if (!_self._parseServerInfo(ret)) {
|
if (!_self._parseServerInfo(ret)) {
|
||||||
return sendMessage('openUrl', [ _self._baseUrlHttp + '/serverinfo?' + _self._buildUidStr()]).then(function(retHttp) {
|
return sendMessage('openUrl', [ _self._baseUrlHttp + '/serverinfo?' + _self._buildUidStr(), false]).then(function(retHttp) {
|
||||||
_self._parseServerInfo(retHttp);
|
_self._parseServerInfo(retHttp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ NvHTTP.prototype = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return sendMessage('openUrl', [_self._baseUrlHttps + '/applist?' + _self._buildUidStr()]).then(function (ret) {
|
return sendMessage('openUrl', [_self._baseUrlHttps + '/applist?' + _self._buildUidStr(), false]).then(function (ret) {
|
||||||
$xml = _self._parseXML(ret);
|
$xml = _self._parseXML(ret);
|
||||||
|
|
||||||
var rootElement = $xml.find("root")[0];
|
var rootElement = $xml.find("root")[0];
|
||||||
@ -146,10 +146,9 @@ NvHTTP.prototype = {
|
|||||||
_self._baseUrlHttps +
|
_self._baseUrlHttps +
|
||||||
'/appasset?'+_self._buildUidStr() +
|
'/appasset?'+_self._buildUidStr() +
|
||||||
'&appid=' + appId +
|
'&appid=' + appId +
|
||||||
'&AssetType=2&AssetIdx=0'
|
'&AssetType=2&AssetIdx=0',
|
||||||
]).then(function (ret) {
|
true
|
||||||
return ret;
|
]);
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
launchApp: function (appId, mode, sops, rikey, rikeyid, localAudio, surroundAudioInfo) {
|
launchApp: function (appId, mode, sops, rikey, rikeyid, localAudio, surroundAudioInfo) {
|
||||||
@ -162,7 +161,8 @@ NvHTTP.prototype = {
|
|||||||
'&rikey=' + rikey +
|
'&rikey=' + rikey +
|
||||||
'&rikeyid=' + rikeyid +
|
'&rikeyid=' + rikeyid +
|
||||||
'&localAudioPlayMode=' + localAudio +
|
'&localAudioPlayMode=' + localAudio +
|
||||||
'&surroundAudioInfo=' + surroundAudioInfo
|
'&surroundAudioInfo=' + surroundAudioInfo,
|
||||||
|
false
|
||||||
]).then(function (ret) {
|
]).then(function (ret) {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@ -173,14 +173,15 @@ NvHTTP.prototype = {
|
|||||||
_self._baseUrlHttps +
|
_self._baseUrlHttps +
|
||||||
'/resume?' + _self._buildUidStr() +
|
'/resume?' + _self._buildUidStr() +
|
||||||
'&rikey=' + rikey +
|
'&rikey=' + rikey +
|
||||||
'&rikeyid=' + rikeyid
|
'&rikeyid=' + rikeyid,
|
||||||
|
false
|
||||||
]).then(function (ret) {
|
]).then(function (ret) {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
quitApp: function () {
|
quitApp: function () {
|
||||||
return sendMessage('openUrl', [_self._baseUrlHttps + '/cancel?' + _self._buildUidStr()]).then(function () {
|
return sendMessage('openUrl', [_self._baseUrlHttps + '/cancel?' + _self._buildUidStr(), false]).then(function () {
|
||||||
_self.currentGame = 0;
|
_self.currentGame = 0;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -194,7 +195,7 @@ NvHTTP.prototype = {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
return sendMessage('pair', [_self.serverMajorVersion, _self.address, randomNumber]).then(function (pairStatus) {
|
return sendMessage('pair', [_self.serverMajorVersion, _self.address, randomNumber]).then(function (pairStatus) {
|
||||||
return sendMessage('openUrl', [_self._baseUrlHttps + '/pair?uniqueid=' + _self.clientUid + '&devicename=roth&updateState=1&phrase=pairchallenge']).then(function (ret) {
|
return sendMessage('openUrl', [_self._baseUrlHttps + '/pair?uniqueid=' + _self.clientUid + '&devicename=roth&updateState=1&phrase=pairchallenge', false]).then(function (ret) {
|
||||||
$xml = _self._parseXML(ret);
|
$xml = _self._parseXML(ret);
|
||||||
_self.paired = $xml.find('paired').html() == "1";
|
_self.paired = $xml.find('paired').html() == "1";
|
||||||
return _self.paired;
|
return _self.paired;
|
||||||
@ -204,7 +205,7 @@ NvHTTP.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
unpair: function () {
|
unpair: function () {
|
||||||
return sendMessage('openUrl', [_self._baseUrlHttps + '/unpair?' + _self._buildUidStr()]);
|
return sendMessage('openUrl', [_self._baseUrlHttps + '/unpair?' + _self._buildUidStr(), false]);
|
||||||
},
|
},
|
||||||
|
|
||||||
_buildUidStr: function () {
|
_buildUidStr: function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user