@@ -78,21 +78,21 @@ StreamingView::StreamingView(const Host& host, const AppInfo& app) : host(host),
7878 keyboardHolder->setAlignItems (AlignItems::STRETCH);
7979 addView (keyboardHolder);
8080
81+ session = new MoonlightSession (host.address , app.app_id );
82+
8183#ifdef PLATFORM_TVOS
8284 updatePreferredDisplayMode (true );
8385#endif
8486
8587 ASYNC_RETAIN
8688 GameStreamClient::instance ().connect (
87- host.address , [ASYNC_TOKEN, host, app ](GSResult<SERVER_DATA> result) {
89+ host.address , [ASYNC_TOKEN](GSResult<SERVER_DATA> result) {
8890 ASYNC_RELEASE
8991 if (!result.isSuccess ()) {
9092 showError (result.error (), [this ]() { terminate (false ); });
9193 return ;
9294 }
9395
94- session = new MoonlightSession (host.address , app.app_id , result.value ().isSunshine ());
95-
9696 ASYNC_RETAIN
9797 session->start ([ASYNC_TOKEN](GSResult<bool > result) {
9898 ASYNC_RELEASE
@@ -101,7 +101,7 @@ StreamingView::StreamingView(const Host& host, const AppInfo& app) : host(host),
101101 if (!result.isSuccess ()) {
102102 showError (result.error (), [this ]() { terminate (false ); });
103103 }
104- });
104+ }, result. value (). isSunshine () );
105105 });
106106
107107 MoonlightInputManager::instance ().reloadButtonMappingLayout ();
@@ -281,8 +281,6 @@ void StreamingView::onFocusLost() {
281281
282282void StreamingView::draw (NVGcontext* vg, float x, float y, float width,
283283 float height, Style style, FrameContext* ctx) {
284- if (!session) return ;
285-
286284 if (session->is_terminated ()) {
287285 terminate (false );
288286 return ;
@@ -555,9 +553,6 @@ StreamingView::~StreamingView() {
555553 ->getInputManager ()
556554 ->getKeyboardKeyStateChanged ()
557555 ->unsubscribe (keysSubscription);
558-
559- if (session) {
560- session->stop (false );
561- delete session;
562- }
556+ session->stop (false );
557+ delete session;
563558}
0 commit comments