中间件底层,websocket

RcfClient.cpp 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. // RcfClient.cpp : 定义静态库的函数。
  2. //
  3. #include <iostream>
  4. #include "RcfClient.h"
  5. #include "RCF\RcfInterface.h"
  6. #include "RCF\RcfConfig.h"
  7. bool pushAgentList(int agentId, std::string agentList)
  8. {
  9. try
  10. {
  11. RCF::RcfInit rcfInit;
  12. auto pCfg = RcfConfig::GetInstance();
  13. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  14. client.getClientStub().setServerBindingName("agent");
  15. bool ret = client.pushAgentList(agentId, agentList);
  16. return ret;
  17. }
  18. catch (const RCF::Exception & e)
  19. {
  20. std::cout << e.getErrorMessage() << std::endl;
  21. return false;
  22. }
  23. return true;
  24. }
  25. bool getAgentList(int agentId, std::string & agentList)
  26. {
  27. try
  28. {
  29. RCF::RcfInit rcfInit;
  30. auto pCfg = RcfConfig::GetInstance();
  31. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  32. client.getClientStub().setServerBindingName("agent");
  33. bool ret = client.getAgentList(agentId, agentList);
  34. return ret;
  35. }
  36. catch (const RCF::Exception & e)
  37. {
  38. std::cout << e.getErrorMessage() << std::endl;
  39. return false;
  40. }
  41. return true;
  42. }
  43. bool pushRedis(std::vector<std::string>& val)
  44. {
  45. try
  46. {
  47. RCF::RcfInit rcfInit;
  48. auto pCfg = RcfConfig::GetInstance();
  49. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  50. client.getClientStub().setServerBindingName("agent");
  51. bool ret = client.pushRedis(val);
  52. return ret;
  53. }
  54. catch (const RCF::Exception & e)
  55. {
  56. std::cout << e.getErrorMessage() << std::endl;
  57. return false;
  58. }
  59. return true;
  60. }
  61. bool pushRedis(std::string & val)
  62. {
  63. try
  64. {
  65. RCF::RcfInit rcfInit;
  66. auto pCfg = RcfConfig::GetInstance();
  67. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  68. client.getClientStub().setServerBindingName("agent");
  69. std::vector<std::string> vec;
  70. vec.emplace_back(val);
  71. bool ret = client.pushRedis(vec);
  72. return ret;
  73. }
  74. catch (const RCF::Exception & e)
  75. {
  76. std::cout << e.getErrorMessage() << std::endl;
  77. return false;
  78. }
  79. return true;
  80. }
  81. bool pushCallIndex(std::string callIndex)
  82. {
  83. try
  84. {
  85. RCF::RcfInit rcfInit;
  86. auto pCfg = RcfConfig::GetInstance();
  87. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  88. client.getClientStub().setServerBindingName("agent");
  89. bool ret = client.pushCallIndex(callIndex);
  90. return ret;
  91. }
  92. catch (const RCF::Exception & e)
  93. {
  94. std::cout << e.getErrorMessage() << std::endl;
  95. return false;
  96. }
  97. return true;
  98. }
  99. bool getCallIndex(int index, std::string & callIndex)
  100. {
  101. try
  102. {
  103. RCF::RcfInit rcfInit;
  104. auto pCfg = RcfConfig::GetInstance();
  105. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  106. client.getClientStub().setServerBindingName("agent");
  107. //client.getClientStub().setConnectTimeoutMs(1 * 1000);
  108. //client.getClientStub().setRemoteCallTimeoutMs(1 * 1000);
  109. bool ret = client.getCallIndex(index,callIndex);
  110. return ret;
  111. }
  112. catch (const RCF::Exception & e)
  113. {
  114. std::cout << e.getErrorMessage() << std::endl;
  115. return false;
  116. }
  117. return true;
  118. }
  119. bool pushSubmitData(int nAgentID, int nEventType, std::string state)
  120. {
  121. try
  122. {
  123. RCF::RcfInit rcfInit;
  124. auto pCfg = RcfConfig::GetInstance();
  125. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  126. client.getClientStub().setServerBindingName("agent");
  127. bool ret = client.pushSubmitData(nAgentID, nEventType, state);
  128. return ret;
  129. }
  130. catch (const RCF::Exception & e)
  131. {
  132. std::cout << e.getErrorMessage() << std::endl;
  133. return false;
  134. }
  135. return true;
  136. }
  137. bool getSubmitData(int nAgentID, int nEventType, std::string & state)
  138. {
  139. try
  140. {
  141. RCF::RcfInit rcfInit;
  142. auto pCfg = RcfConfig::GetInstance();
  143. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  144. client.getClientStub().setServerBindingName("agent");
  145. bool ret = client.getSubmitData(nAgentID, nEventType, state);
  146. return ret;
  147. }
  148. catch (const RCF::Exception & e)
  149. {
  150. std::cout << e.getErrorMessage() << std::endl;
  151. return false;
  152. }
  153. return true;
  154. }
  155. bool pushZmdExtenStateList(std::string & extList)
  156. {
  157. try
  158. {
  159. RCF::RcfInit rcfInit;
  160. auto pCfg = RcfConfig::GetInstance();
  161. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  162. client.getClientStub().setServerBindingName("agent");
  163. bool ret = client.pushZmdExtenStateList(extList);
  164. return ret;
  165. }
  166. catch (const RCF::Exception & e)
  167. {
  168. std::cout << e.getErrorMessage() << std::endl;
  169. return false;
  170. }
  171. return true;
  172. }
  173. bool getZmdExtenStateList(std::string & extList)
  174. {
  175. try
  176. {
  177. RCF::RcfInit rcfInit;
  178. auto pCfg = RcfConfig::GetInstance();
  179. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  180. client.getClientStub().setServerBindingName("agent");
  181. bool ret = client.getZmdExtenStateList(extList);
  182. return ret;
  183. }
  184. catch (const RCF::Exception & e)
  185. {
  186. std::cout << e.getErrorMessage() << std::endl;
  187. return false;
  188. }
  189. return true;
  190. }
  191. bool pushOnlineAgentGroupDetail(std::string & groupNo, std::string & agentList)
  192. {
  193. try
  194. {
  195. RCF::RcfInit rcfInit;
  196. auto pCfg = RcfConfig::GetInstance();
  197. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  198. client.getClientStub().setServerBindingName("agent");
  199. client.getClientStub().setConnectTimeoutMs(1 * 1000);
  200. bool ret = client.pushOnlineAgentGroupDetail(groupNo,agentList);
  201. return ret;
  202. }
  203. catch (const RCF::Exception & e)
  204. {
  205. std::cout << e.getErrorMessage() << std::endl;
  206. return false;
  207. }
  208. return true;
  209. }
  210. bool getOnlineAgentGroupDetail(std::vector<std::string>& agentList)
  211. {
  212. try
  213. {
  214. RCF::RcfInit rcfInit;
  215. auto pCfg = RcfConfig::GetInstance();
  216. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  217. client.getClientStub().setServerBindingName("agent");
  218. bool ret = client.getOnlineAgentGroupDetail(agentList);
  219. return ret;
  220. }
  221. catch (const RCF::Exception & e)
  222. {
  223. std::cout << e.getErrorMessage() << std::endl;
  224. return false;
  225. }
  226. return true;
  227. }
  228. bool delOnlineAgentGroupDetail(int agentID, int extenNo)
  229. {
  230. try
  231. {
  232. RCF::RcfInit rcfInit;
  233. auto pCfg = RcfConfig::GetInstance();
  234. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  235. client.getClientStub().setServerBindingName("agent");
  236. bool ret = client.delOnlineAgentGroupDetail(agentID, extenNo);
  237. return ret;
  238. }
  239. catch (const RCF::Exception & e)
  240. {
  241. std::cout << e.getErrorMessage() << std::endl;
  242. return false;
  243. }
  244. return true;
  245. }
  246. bool clearOnlineAgentGroupDetail()
  247. {
  248. try
  249. {
  250. RCF::RcfInit rcfInit;
  251. auto pCfg = RcfConfig::GetInstance();
  252. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  253. client.getClientStub().setServerBindingName("agent");
  254. bool ret = client.clearOnlineAgentGroupDetail( );
  255. return ret;
  256. }
  257. catch (const RCF::Exception & e)
  258. {
  259. std::cout << e.getErrorMessage() << std::endl;
  260. return false;
  261. }
  262. return true;
  263. }
  264. bool pushCtiState(bool isRun)
  265. {
  266. try
  267. {
  268. RCF::RcfInit rcfInit;
  269. auto pCfg = RcfConfig::GetInstance();
  270. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  271. client.getClientStub().setServerBindingName("agent");
  272. bool ret = client.pushCtiState(isRun);
  273. return ret;
  274. }
  275. catch (const RCF::Exception & e)
  276. {
  277. std::cout << e.getErrorMessage() << std::endl;
  278. return false;
  279. }
  280. return true;
  281. }
  282. bool getCtiState()
  283. {
  284. try
  285. {
  286. RCF::RcfInit rcfInit;
  287. auto pCfg = RcfConfig::GetInstance();
  288. RcfClient<I_RcfEcho> client(RCF::TcpEndpoint(pCfg->RcfIP(), pCfg->RcfPort()));
  289. client.getClientStub().setServerBindingName("agent");
  290. bool ret = client.getCtiState();
  291. return ret;
  292. }
  293. catch (const RCF::Exception & e)
  294. {
  295. std::cout << e.getErrorMessage() << std::endl;
  296. return false;
  297. }
  298. return true;
  299. }