Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.6 KiB

  1. // WatcherTCClient.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "WATCHER.h"
  5. #include "WatcherTCClient.h"
  6. #include "WATCHERView.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // WatcherTCClient
  14. WatcherTCClient::WatcherTCClient(LPBYTE cmd, int cmdLen)
  15. {
  16. DocView = NULL;
  17. lenCommand = cmdLen;
  18. Command = cmd;
  19. }
  20. WatcherTCClient::~WatcherTCClient()
  21. {
  22. if(Command){
  23. delete [] Command;
  24. Command = NULL;
  25. }
  26. WatcherSocket::~WatcherSocket();
  27. }
  28. // Do not edit the following lines, which are needed by ClassWizard.
  29. #if 0
  30. BEGIN_MESSAGE_MAP(WatcherTCClient, WatcherSocket)
  31. //{{AFX_MSG_MAP(WatcherTCClient)
  32. //}}AFX_MSG_MAP
  33. END_MESSAGE_MAP()
  34. #endif // 0
  35. /////////////////////////////////////////////////////////////////////////////
  36. // WatcherTCClient member functions
  37. void WatcherTCClient::OnClose(int nErrorCode)
  38. {
  39. BOOL ret = (DocView->GetParent())->PostMessage(WM_CLOSE,0,0);
  40. WatcherSocket::OnClose(nErrorCode);
  41. return;
  42. }
  43. void WatcherTCClient::OnReceive(int nErrorCode)
  44. {
  45. BYTE Buffer[MAX_BUFFER_SIZE];
  46. int i,nRet;
  47. if (nErrorCode != 0) {
  48. (DocView->GetParent())->PostMessage(WM_CLOSE, 0,0);
  49. return;
  50. }
  51. nRet = Receive(Buffer, MAX_BUFFER_SIZE, 0);
  52. if(nRet <= 0) return;
  53. for(i=0;i<nRet;i++){
  54. ((CWatcherView *)DocView)->ProcessByte(Buffer[i]);
  55. }
  56. WatcherSocket::OnReceive(nErrorCode);
  57. return;
  58. }