mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
Add connection termination message for unexpected terminations
This commit is contained in:
parent
b48cb3d069
commit
87f6f14af6
8
main.cpp
8
main.cpp
@ -18,7 +18,7 @@
|
|||||||
// Requests the NaCl module stop streaming
|
// Requests the NaCl module stop streaming
|
||||||
#define MSG_STOP_REQUEST "stopRequest"
|
#define MSG_STOP_REQUEST "stopRequest"
|
||||||
// Sent by the NaCl module when the stream has stopped whether user-requested or not
|
// Sent by the NaCl module when the stream has stopped whether user-requested or not
|
||||||
#define MSG_STREAM_TERMINATED "streamTerminated"
|
#define MSG_STREAM_TERMINATED "streamTerminated: "
|
||||||
|
|
||||||
#define MSG_OPENURL "openUrl"
|
#define MSG_OPENURL "openUrl"
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ void MoonlightInstance::OnConnectionStopped(uint32_t error) {
|
|||||||
UnlockMouse();
|
UnlockMouse();
|
||||||
|
|
||||||
// Notify the JS code that the stream has ended
|
// Notify the JS code that the stream has ended
|
||||||
pp::Var response(MSG_STREAM_TERMINATED);
|
pp::Var response(std::string(MSG_STREAM_TERMINATED) + std::to_string((int)error));
|
||||||
PostMessage(response);
|
PostMessage(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,9 @@ void* MoonlightInstance::ConnectionThreadFunc(void* context) {
|
|||||||
NULL, 0);
|
NULL, 0);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
// Notify the JS code that the stream has ended
|
// Notify the JS code that the stream has ended
|
||||||
pp::Var response(MSG_STREAM_TERMINATED);
|
// NB: We pass error code 0 here to avoid triggering a "Connection terminated"
|
||||||
|
// warning message.
|
||||||
|
pp::Var response(MSG_STREAM_TERMINATED + std::to_string(0));
|
||||||
me->PostMessage(response);
|
me->PostMessage(response);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,16 @@ function handleMessage(msg) {
|
|||||||
delete callbacks[msg.data.callbackId]
|
delete callbacks[msg.data.callbackId]
|
||||||
} else { // else, it's just info, or an event
|
} else { // else, it's just info, or an event
|
||||||
console.log('%c[messages.js, handleMessage]', 'color:gray;', 'Message data: ', msg.data)
|
console.log('%c[messages.js, handleMessage]', 'color:gray;', 'Message data: ', msg.data)
|
||||||
if (msg.data === 'streamTerminated') { // if it's a recognized event, notify the appropriate function
|
if (msg.data.indexOf('streamTerminated: ') === 0) { // if it's a recognized event, notify the appropriate function
|
||||||
// Release our keep awake request
|
// Release our keep awake request
|
||||||
chrome.power.releaseKeepAwake();
|
chrome.power.releaseKeepAwake();
|
||||||
|
|
||||||
|
// Show a termination snackbar message if the termination was unexpected
|
||||||
|
var errorCode = parseInt(msg.data.replace('streamTerminated: ', ''));
|
||||||
|
if (errorCode !== 0) {
|
||||||
|
snackbarLogLong("Connection terminated");
|
||||||
|
}
|
||||||
|
|
||||||
api.refreshServerInfo().then(function(ret) {
|
api.refreshServerInfo().then(function(ret) {
|
||||||
// Return to app list with new currentgame
|
// Return to app list with new currentgame
|
||||||
showApps(api);
|
showApps(api);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user