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.

65 lines
1.5 KiB

7 years ago
6 years ago
7 years ago
​
​
​
​
​
7 years ago
7 years ago
​
​
​
​
​
​
7 years ago
​
7 years ago
​
7 years ago
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
7 years ago
​
7 years ago
​
7 years ago
7 years ago
​
  1. #include "basicTransport.h"
  2. #include "../../data/protocol/protocol.h"
  3. #define LOG(X) m_pLog->Log("BTRANS", this, X)
  4. #define LOG_ERROR(X) m_pLog->Log("BTRANS", this, _LOG_ERROR, X)
  5. basicTransport::basicTransport() :
  6. m_mQueueProtectorMutex(),
  7. m_mBufferProtectorMutex()
  8. {
  9. m_pLog = basicLogCollection::getInstance();
  10. m_eConnectionStatus = CS_UNKNOWN;
  11. }
  12. basicTransport::~basicTransport()
  13. {
  14. // ToDo: Cleanup parsers vector
  15. m_mQueueProtectorMutex.lock();
  16. m_vParsers.clear();
  17. m_mQueueProtectorMutex.unlock();
  18. }
  19. bool basicTransport::addRecipient(protocolParser * ProtoParser)
  20. {
  21. m_mQueueProtectorMutex.lock();
  22. m_vParsers.push_back(ProtoParser);
  23. ProtoParser->setConnectionStatus(m_eConnectionStatus);
  24. m_mQueueProtectorMutex.unlock();
  25. return true;
  26. }
  27. bool basicTransport::removeRecipient(protocolParser * ProtoParser)
  28. {
  29. m_mQueueProtectorMutex.lock();
  30. parseQueue::iterator it = std::find(m_vParsers.begin(), m_vParsers.end(), ProtoParser);
  31. if (it != m_vParsers.end())
  32. {
  33. m_vParsers.erase(it);
  34. m_mQueueProtectorMutex.unlock();
  35. return true;
  36. };
  37. m_mQueueProtectorMutex.unlock();
  38. return false;
  39. }
  40. void basicTransport::setConnectionStatus(CONNECTION_STATUS CS)
  41. {
  42. m_mQueueProtectorMutex.lock();
  43. m_eConnectionStatus = CS;
  44. for (parseQueue::iterator index = m_vParsers.begin(); index != m_vParsers.end(); index++)
  45. {
  46. (*index)->setConnectionStatus(m_eConnectionStatus);
  47. };
  48. m_mQueueProtectorMutex.unlock();
  49. }
  50. CONNECTION_STATUS basicTransport::getConnectionStatus(void)
  51. {
  52. return m_eConnectionStatus;
  53. }
  54. #undef LOG
  55. #undef LOG_ERROR