[Sphere-axis-commits] CVS: Axis RemoteConsole.cpp,1.7,1.8 RemoteConsoleDlg.cpp,1.7,1.8
Brought to you by:
pesterle
From: Philip E. <pes...@us...> - 2002-05-10 19:22:49
|
Update of /cvsroot/sphere-axis/Axis In directory usw-pr-cvs1:/tmp/cvs-serv21125 Modified Files: RemoteConsole.cpp RemoteConsoleDlg.cpp Log Message: Tweaked the remote console a bit. Errors should be more visible, and hopefully more useful. Index: RemoteConsole.cpp =================================================================== RCS file: /cvsroot/sphere-axis/Axis/RemoteConsole.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** RemoteConsole.cpp 1 May 2002 03:33:10 -0000 1.7 --- RemoteConsole.cpp 10 May 2002 19:22:47 -0000 1.8 *************** *** 125,128 **** --- 125,129 ---- UINT MainThread(LPVOID lpData) { + BYTE szBuffer[MAX_BUFFER]; CRemoteConsole * pConsole = (CRemoteConsole *) lpData; if (pConsole == NULL) *************** *** 153,159 **** { pConsole->m_bIsInitialized = true; ! DWORD dwErr = GetLastError(); CString csMessage; ! csMessage.Format("Could not connect to the remote console: dwErr = %ld\nHost = %s, Port =%ld\nThis is usually because the Sphere server isn't running.", dwErr, pConsole->m_csHostAddress, pConsole->m_nHostPort); //AfxMessageBox(csMessage, MB_OK | MB_ICONEXCLAMATION); closesocket(sock.m_hSocket); --- 154,170 ---- { pConsole->m_bIsInitialized = true; ! char szError[MAX_BUFFER]; ! FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, &szError[0], MAX_BUFFER, NULL); ! CString csError; ! csError.Format("%s", szError); ! char crlf [3] = { 0x0d, 0x0a, 0x00 }; ! csError.Replace(crlf, ""); CString csMessage; ! csMessage.Format("Could not connect to the remote console --\nLast Error was \"%s\"\nHost = %s, Port =%ld\nThis is usually because the Sphere server isn't running.\n", csError , pConsole->m_csHostAddress, pConsole->m_nHostPort); ! memset(&szBuffer[0], 0x00, MAX_BUFFER); ! memcpy(&szBuffer[0], LPCTSTR(csMessage), csMessage.GetLength()); ! if ( pConsole->m_parentHWnd != NULL ) ! SendMessage(pConsole->m_parentHWnd, WM_RCONSOLEMESSAGE, (WPARAM) &szBuffer[0], 0); ! //AfxMessageBox(csMessage, MB_OK | MB_ICONEXCLAMATION); closesocket(sock.m_hSocket); *************** *** 164,168 **** } // Log on. - BYTE szBuffer[MAX_BUFFER]; memset(&szBuffer[0], 0x00, sizeof(szBuffer)); szBuffer[0] = (char) 0x20; --- 175,178 ---- *************** *** 173,177 **** CString csMessage; DWORD dwErr = GetLastError(); ! csMessage.Format("Error while sending login info to the remote console: dwErr = %ld\nIs the TUS server running?", dwErr); AfxMessageBox(csMessage, MB_OK | MB_ICONEXCLAMATION); pConsole->m_bIsInitialized = true; --- 183,187 ---- CString csMessage; DWORD dwErr = GetLastError(); ! csMessage.Format("Error while sending login info to the remote console: dwErr = %ld\nIs the Sphere server running?", dwErr); AfxMessageBox(csMessage, MB_OK | MB_ICONEXCLAMATION); pConsole->m_bIsInitialized = true; *************** *** 197,201 **** if ( rc < 0 ) { ! Main->m_log.Add("Socket error on select(): %ld - %s", WSAGetLastError(), strerror(WSAGetLastError())); closesocket(sock.m_hSocket); sock.m_hSocket = INVALID_SOCKET; --- 207,214 ---- if ( rc < 0 ) { ! CString csMessage; ! csMessage.Format("Socket error on select(): %ld - %s", WSAGetLastError(), strerror(WSAGetLastError())); ! Main->m_log.Add(csMessage); ! AfxMessageBox(csMessage, MB_OK | MB_ICONEXCLAMATION); closesocket(sock.m_hSocket); sock.m_hSocket = INVALID_SOCKET; *************** *** 206,210 **** if ( rc == 0 && i++ > Main->m_iReceiveTimeout ) { ! Main->m_log.Add("Timeout exceeded while receiving data from remote server."); closesocket(sock.m_hSocket); sock.m_hSocket = INVALID_SOCKET; --- 219,226 ---- if ( rc == 0 && i++ > Main->m_iReceiveTimeout ) { ! CString csMessage; ! csMessage.Format("Timeout exceeded while receiving data from remote server."); ! Main->m_log.Add(csMessage); ! AfxMessageBox(csMessage, MB_OK | MB_ICONEXCLAMATION); closesocket(sock.m_hSocket); sock.m_hSocket = INVALID_SOCKET; *************** *** 247,251 **** CString csMessage; DWORD dwErr = GetLastError(); ! csMessage.Format("Error while sending password to the remote console: dwErr = %ld\nIs the TUS server still running?", dwErr); AfxMessageBox(csMessage, MB_OK | MB_ICONEXCLAMATION); pConsole->m_bIsInitialized = true; --- 263,267 ---- CString csMessage; DWORD dwErr = GetLastError(); ! csMessage.Format("Error while sending password to the remote console: dwErr = %ld\nIs the Sphere server still running?", dwErr); AfxMessageBox(csMessage, MB_OK | MB_ICONEXCLAMATION); pConsole->m_bIsInitialized = true; *************** *** 259,262 **** --- 275,280 ---- pConsole->m_bIsInitialized = true; i = 0; + + // Here's the main loop while (pConsole->m_bContinue) { *************** *** 289,304 **** { // Socket error ! memcpy(&szBuffer[0], "Connection closed.", 18); if(pConsole->m_parentHWnd != NULL) SendMessage(pConsole->m_parentHWnd, WM_RCONSOLEMESSAGE, (WPARAM) &szBuffer[0], 0); break; } - /* - if ( i++ > Main->m_iReceiveTimeout ) - { - Main->m_log.Add("Timeout exceeded while receiving data from remote server."); - break; - } - */ if (pConsole->m_bCommandPending) { --- 307,324 ---- { // Socket error ! char szError[MAX_BUFFER]; ! FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, &szError[0], MAX_BUFFER, NULL); ! CString csError; ! csError.Format("%s", szError); ! char crlf[3] = { 0x0d, 0x0a, 0x00}; ! csError.Replace(crlf, ""); ! CString csMessage; ! csMessage.Format("Connection lost. Last Error was \"%s\"\n", csError); ! memset(&szBuffer[0], 0x00, MAX_BUFFER); ! memcpy(&szBuffer[0], LPCTSTR(csMessage), csMessage.GetLength()); if(pConsole->m_parentHWnd != NULL) SendMessage(pConsole->m_parentHWnd, WM_RCONSOLEMESSAGE, (WPARAM) &szBuffer[0], 0); break; } if (pConsole->m_bCommandPending) { *************** *** 312,317 **** --- 332,348 ---- } } + if ( !pConsole->m_bContinue) + { + // We were told to stop + char szMessage[256]; + sprintf(szMessage, "Disconnecting from remote server..."); + memset(&szBuffer[0], 0x00, MAX_BUFFER); + memcpy(&szBuffer[0], &szMessage[0], strlen(szMessage)); + if ( pConsole->m_parentHWnd != NULL ) + SendMessage(pConsole->m_parentHWnd, WM_RCONSOLEMESSAGE, (WPARAM) &szBuffer[0], 0); + } // Disconnect the socket closesocket(sock.m_hSocket); + sock.m_hSocket = INVALID_SOCKET; pConsole->m_bCommandPending = false; Index: RemoteConsoleDlg.cpp =================================================================== RCS file: /cvsroot/sphere-axis/Axis/RemoteConsoleDlg.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** RemoteConsoleDlg.cpp 2 May 2002 22:19:57 -0000 1.7 --- RemoteConsoleDlg.cpp 10 May 2002 19:22:47 -0000 1.8 *************** *** 140,152 **** if (m_bIsConnected) { ! this->m_cbReconnect.SetWindowText("ReConnect"); m_bIsConnected = false; this->m_rConsole->m_bContinue = false; int i = 0; ! while (this->m_rConsole->IsConnected() && i < 100) ! { ! i++; ! Sleep(100); ! } } else --- 140,148 ---- if (m_bIsConnected) { ! CWaitCursor hourglass; m_bIsConnected = false; this->m_rConsole->m_bContinue = false; int i = 0; ! this->m_cbReconnect.SetWindowText("ReConnect"); } else |