From f762ecc3b2c56dffe7a99494969a483e23b4f1cf Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Fri, 5 Jun 2026 16:53:40 +0800 Subject: [PATCH] detailed definitions for connection termination errors --- .../StreamFrameViewController.m | 37 +++++++++++++++++++ moonlight-common/moonlight-common-c | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/VoidLink/ViewControllers/StreamFrameViewController.m b/VoidLink/ViewControllers/StreamFrameViewController.m index def40ab4..b617dc0a 100644 --- a/VoidLink/ViewControllers/StreamFrameViewController.m +++ b/VoidLink/ViewControllers/StreamFrameViewController.m @@ -31,6 +31,7 @@ #include #include #include +#include #include #if TARGET_OS_TV @@ -45,6 +46,37 @@ - (id)initWithRefreshRate:(float)arg1 videoDynamicRange:(int)arg2; @end +static NSString* VLTerminationHintForErrorCode(int errorCode) { + switch (errorCode) { + case ML_ERROR_CONTROL_DISCONNECT_TIMEOUT: + return @"Timeout type: control disconnect timeout.\nThe control stream started disconnecting, but the final disconnect event never arrived before the timeout expired."; + case ML_ERROR_CONTROL_UNEXPECTED_DISCONNECT: + return @"Timeout type: enet peer timeout disconnect / unexpected control stream disconnect.\nThe established control stream was dropped by ENet or the host/network unexpectedly."; + case -1: + return @"Possible causes:\n- control disconnect timeout\n- enet peer timeout disconnect\n- unexpected control stream disconnect\n- video receive socket failure\n- audio receive socket failure\n- input send socket failure\n- control message send/ack failure\n- loss stats/control buffer malloc failure\n- video buffer malloc failure\n- audio packet malloc failure\n- unknown socket failure"; + case ETIMEDOUT: + return @"Timeout type: socket or control channel timeout."; + case ECONNRESET: + return @"Possible cause: the host or network reset the connection."; + case EPIPE: + return @"Possible cause: write failed because the peer closed the connection."; + case ECONNABORTED: + return @"Possible cause: the local network stack aborted the connection."; + case ENETDOWN: + return @"Possible cause: the local network interface went down."; + case ENETUNREACH: + return @"Possible cause: the network became unreachable."; + case EHOSTUNREACH: + return @"Possible cause: the host became unreachable."; + case ENOBUFS: + return @"Possible cause: the network stack ran out of buffer space."; + case ENOMEM: + return @"Possible cause: memory allocation failed."; + default: + return nil; + } +} + @implementation StreamFrameViewController { ControllerSupport *_controllerSupport; @@ -1608,6 +1640,7 @@ default: { NSString* errorString; + NSString* errorHint; if (abs(errorCode) > 1000) { // We'll assume large errors are hex values errorString = [NSString stringWithFormat:@"%08X", (uint32_t)errorCode]; @@ -1616,9 +1649,13 @@ // Smaller values will just be printed as decimal (probably errno.h values) errorString = [NSString stringWithFormat:@"%d", errorCode]; } + errorHint = VLTerminationHintForErrorCode(errorCode); title = [LocalizationHelper localizedStringForKey: @"Connection Terminated"]; message = [LocalizationHelper localizedStringForKey: @"The connection was terminated, Error code: %@", errorString]; + if (errorHint != nil) { + message = [message stringByAppendingFormat:@"\n\n%@", errorHint]; + } break; } } diff --git a/moonlight-common/moonlight-common-c b/moonlight-common/moonlight-common-c index ea507a13..48c4572c 160000 --- a/moonlight-common/moonlight-common-c +++ b/moonlight-common/moonlight-common-c @@ -1 +1 @@ -Subproject commit ea507a137dd8852d6c7b6bd2ede7e48f11cc9f1c +Subproject commit 48c4572c7194c7e116cbcf62ea6985920f76422c