-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExchangeCommunicator.cpp
105 lines (75 loc) · 2.36 KB
/
ExchangeCommunicator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// ExchangeCommunicator.cpp: implementation of the ExchangeCommunicator class.
//
//////////////////////////////////////////////////////////////////////
#include "ExchangeCommunicator.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CExchangeCommunicator::CExchangeCommunicator(STExchangeConnectionInfo _ExConInfo)
{
m_ExeConInfo = _ExConInfo;
// Service Handler
this->m_ExDataHandler = new CExchangeDataHandler(this);
this->m_MessageParser = new CMessageParserADSM(this->m_QueueRawMsg, this->m_QueueParsedMessage);
// Raw Queue
this->m_QueueRawMsg = new CQueue<std::string>();
this->m_Publisher = new CPublisher(this);
// Parsed Message Queue
this->m_QueueParsedMessage = new CQueue<CParsedMessage>();
//Message Parser
switch(_ExConInfo.ParserType)
{
case 0:
this->m_MessageParser = NULL;
break;
case 1:
this->m_MessageParser = NULL;
break;
default:
break;
}
}
int CExchangeCommunicator::ConnectToExchange()
{
//CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CExchangeCommunicator::Start_, this, 0, NULL);
if( ACE_Thread::spawn((ACE_THR_FUNC)CExchangeCommunicator::Start_,
this,
THR_JOINABLE | THR_NEW_LWP,
&m_processorThreadID,
&m_processorThreadHandle ) == -1 )
{
// TODO: Log
}
return 1;
}
//////////////////////////////////////////////////////////////////////////
void CExchangeCommunicator::Start_Callback()
{
std::string p_IP;
std::string p_Exchange;
int p_Port = m_ExeConInfo.Port;
p_IP = m_ExeConInfo.IP;
// Calling Publisher
ACE_INET_Addr oHostAddress(p_Port, p_IP.c_str()) ;
while ( true )
{
if ( m_Connector.connect( m_ExDataHandler, oHostAddress ) == -1 )
{
printf("Failed To Connect %s port \n", m_ExeConInfo.Exchange.c_str() ,m_ExeConInfo.Port );
}
else
{
printf("Connected To %s Port %d\n", m_ExeConInfo.Exchange.c_str() ,m_ExeConInfo.Port );
break;
}
}
}
//////////////////////////////////////////////////////////////////////////
void* CExchangeCommunicator::Start_(void * pParam )
{
((CExchangeCommunicator*)pParam)->Start_Callback();
return 0;
}
CExchangeCommunicator::~CExchangeCommunicator()
{
}