From a68f5c53c9dcd69462ab07b905ee90beee2699b1 Mon Sep 17 00:00:00 2001 From: evanchia Date: Thu, 19 Aug 2021 17:54:48 -0700 Subject: [PATCH] Adds a verification response for the remote console connecting Signed-off-by: evanchia --- Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp | 8 ++++++++ Code/Tools/RemoteConsole/Core/RemoteConsoleCore.h | 1 + .../ly_remote_console/remote_console_commands.py | 12 +++--------- .../tests/unit/test_remote_console_commands.py | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp b/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp index a4e7bd24fa..d0e9e6a760 100644 --- a/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp +++ b/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.cpp @@ -383,6 +383,13 @@ void SRemoteClient::Run() bool ok = true; bool autoCompleteDoneSent = false; + + // Send a message that is used to verify that the Remote Console connected + SNoDataEvent connectMessage; + SRemoteEventFactory::GetInst()->WriteToBuffer(&connectMessage, szBuff, size, kDefaultBufferSize); + ok &= SendPackage(szBuff, size); + ok &= RecvPackage(szBuff, size); + ok &= m_pServer->ReadBuffer(szBuff, size); while (ok) { // read data @@ -531,6 +538,7 @@ SRemoteEventFactory::SRemoteEventFactory() REGISTER_EVENT_NODATA(eCET_Strobo_FrameInfoStart); REGISTER_EVENT_STRING(eCET_Strobo_FrameInfoAdd); + REGISTER_EVENT_NODATA(eCET_ConnectMessage); } ///////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.h b/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.h index 7e22be5735..d9a6f7aba6 100644 --- a/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.h +++ b/Code/Tools/RemoteConsole/Core/RemoteConsoleCore.h @@ -60,6 +60,7 @@ enum EConsoleEventType eCET_Strobo_FrameInfoStart, eCET_Strobo_FrameInfoAdd, + eCET_ConnectMessage, }; struct SRemoteEventFactory; diff --git a/Tools/RemoteConsole/ly_remote_console/ly_remote_console/remote_console_commands.py b/Tools/RemoteConsole/ly_remote_console/ly_remote_console/remote_console_commands.py index 872537bdca..559823c820 100755 --- a/Tools/RemoteConsole/ly_remote_console/ly_remote_console/remote_console_commands.py +++ b/Tools/RemoteConsole/ly_remote_console/ly_remote_console/remote_console_commands.py @@ -27,7 +27,8 @@ CONSOLE_MESSAGE_MAP = { 'COMMAND': BASE_MSG_TYPE + 5, 'AUTOCOMPLETELIST': BASE_MSG_TYPE + 6, 'AUTOCOMPLETELISTDONE': BASE_MSG_TYPE + 7, - 'GAMEPLAYEVENT': BASE_MSG_TYPE + 22 + 'GAMEPLAYEVENT': BASE_MSG_TYPE + 22, + 'CONNECTMESSAGE': BASE_MSG_TYPE + 25, } @@ -295,14 +296,7 @@ class RemoteConsole: self.handlers[key].set() continue - # The very first connection using the socket will return all of the auto complete items, turned off so no one - # wouldn't need to see them - elif message_type == CONSOLE_MESSAGE_MAP['AUTOCOMPLETELIST']: - pass - - # The after the autocompletelists finishes we will be ready to send console commands we determine that by - # looking at for an autocompletelistdone message - elif message_type == CONSOLE_MESSAGE_MAP['AUTOCOMPLETELISTDONE']: + elif message_type == CONSOLE_MESSAGE_MAP['CONNECTMESSAGE']: self.ready.set() # cleanup expect_log_line handers if the matching string was found or timeout happened. diff --git a/Tools/RemoteConsole/ly_remote_console/tests/unit/test_remote_console_commands.py b/Tools/RemoteConsole/ly_remote_console/tests/unit/test_remote_console_commands.py index 51a85f0413..e0ac82eb99 100755 --- a/Tools/RemoteConsole/ly_remote_console/tests/unit/test_remote_console_commands.py +++ b/Tools/RemoteConsole/ly_remote_console/tests/unit/test_remote_console_commands.py @@ -141,11 +141,11 @@ class TestRemoteConsole(): @mock.patch('socket.socket', mock.MagicMock()) @mock.patch('ly_remote_console.remote_console_commands.threading', mock.MagicMock()) - def test_HandleMessage_AutoCompleteListDone_ReadySet(self): + def test_HandleMessage_ConnectMessage_ReadySet(self): rc_instance = remote_console.RemoteConsole() rc_instance.on_display = mock.MagicMock() rc_instance.ready = mock.MagicMock() - msg = b'70' # in python3 socket.recv returns byte array. 7 is AUTOCOMPLETELISTDONE + msg = b'I0' # in python3 socket.recv returns byte array. 7 is AUTOCOMPLETELISTDONE rc_instance._handle_message(msg)