中间件底层,websocket

stdafx.h 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. // stdafx.h : 标准系统包含文件的包含文件,
  2. // 或是经常使用但不常更改的
  3. // 特定于项目的包含文件
  4. #pragma once
  5. #ifndef _SECURE_ATL
  6. #define _SECURE_ATL 1
  7. #endif
  8. #ifndef VC_EXTRALEAN
  9. #define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
  10. #endif
  11. #include "targetver.h"
  12. #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
  13. // 关闭 MFC 对某些常见但经常可放心忽略的警告消息的隐藏
  14. #define _AFX_ALL_WARNINGS
  15. #include <afxwin.h> // MFC 核心组件和标准组件
  16. #include <afxext.h> // MFC 扩展
  17. #include <afxdisp.h> // MFC 自动化类
  18. #ifndef _AFX_NO_OLE_SUPPORT
  19. #include <afxdtctl.h> // MFC 对 Internet Explorer 4 公共控件的支持
  20. #endif
  21. #ifndef _AFX_NO_AFXCMN_SUPPORT
  22. #include <afxcmn.h> // MFC 对 Windows 公共控件的支持
  23. #endif // _AFX_NO_AFXCMN_SUPPORT
  24. #include <afxcontrolbars.h> // 功能区和控件条的 MFC 支持
  25. #include <afxsock.h> // MFC 套接字扩展
  26. //#define ISNEEDMYD // 是否需要满意度 不需要时屏蔽该宏定义
  27. //#define _USE_EHANGCOM //针对不同交换机
  28. //#define _USE_IPO
  29. #define _USE_FS
  30. #include "../Public/GlobalDef/CommonTypeDef.h" // 通用类型定义
  31. #include "../Public/GlobalDef/DevInfoInc.h" // 设备相关类型定义
  32. #include "../public/GlobalDef/DevLinkInc.h" // 底层设备连接接口定义
  33. #ifdef _USE_EHANGCOM
  34. #include "../eHangCom/DeviceLink.h"
  35. #pragma comment(lib, "eHangCom.lib")
  36. #endif
  37. #ifdef _USE_IPO
  38. #include "../IPO/DeviceLink.h"
  39. #pragma comment(lib, "IPO.lib")
  40. #endif
  41. #ifdef _USE_FS
  42. #include "../FsLink/DeviceLink.h"
  43. #pragma comment(lib, "FsLink.lib")
  44. #endif
  45. #define OTL_ORA11G_R2
  46. #include "CtiDataDef.h"
  47. #include "Logger.h" // 日志接口定义
  48. #include "DBCtrl.h" // 数据库接口定义
  49. #include "Inc/CallDetailInc.h" // 统计相关类型定义
  50. #include "..\wsClient\NetInterface.h"
  51. #include "..\pdu\PduEntity.h"
  52. #include "..\pdu\PduDataFormat.h"
  53. //#define _VERSION_EHANG
  54. #include <regex>
  55. #include <string>
  56. #include <json/json.h>
  57. #pragma comment(lib,"jsoncpp_static.lib")
  58. typedef struct tagAsrInfo {
  59. std::string callId; // 通话唯一标识Id
  60. std::string reference; // 录音唯一标识
  61. std::string agentId; // 坐席ID
  62. std::string calledId; // 被叫号码
  63. std::int64_t callStartTime; // 开始呼叫时间
  64. std::string callerId; // 主叫号码
  65. std::string state; // 当前状态 呼叫中calling
  66. std::string direction; // 呼叫方向:CallIn呼入 CallOut呼出
  67. std::string vocDirect; // 角色标识:User用户 Agent坐席
  68. std::int64_t createTime; // 创建时间
  69. std::string audioCode; // 编码格式 pcm8k16b
  70. std::int64_t sentenceBeginTime;// 本句开始时间(相对时间)相对于callStartTime的偏移时间
  71. std::string transSentenceText; // 转写结果
  72. std::int32_t transSentenceIndex;// 句子编号
  73. std::int64_t transSentenceTime; // 本句结束时间(相对时间) 相对于callStartTime的偏移时间
  74. tagAsrInfo() {
  75. this->callId = "";
  76. this->reference = "";
  77. this->agentId = "";
  78. this->calledId = "";
  79. this->callStartTime = 0;
  80. this->callerId = "";
  81. //this->state = "";
  82. this->state = "calling";
  83. this->direction = "";
  84. this->vocDirect = "";
  85. this->createTime = 0;
  86. //this->audioCode = "";
  87. this->audioCode = "pcm8k16b";
  88. this->sentenceBeginTime = 0;
  89. this->transSentenceText = "";
  90. this->transSentenceIndex = 0;
  91. this->transSentenceTime = 0;
  92. }
  93. tagAsrInfo(std::string str) {
  94. JSONCPP_STRING err;
  95. Json::Value root;
  96. Json::CharReaderBuilder builder;
  97. const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
  98. if (!reader->parse(str.c_str(), str.c_str() + str.length(), &root, &err))
  99. {
  100. return;
  101. }
  102. this->callId = root["callId"].asString();
  103. this->reference = root["reference"].asString();
  104. this->agentId = root["agentId"].asString();
  105. this->calledId = root["calledId"].asString();
  106. this->callStartTime = root["callStartTime"].asInt64();
  107. this->callerId = root["callerId"].asString();
  108. //this->state = root["state"].asString();
  109. this->state = "calling";
  110. this->direction = root["direction"].asString();
  111. this->vocDirect = root["vocDirect"].asString();
  112. this->createTime = root["createTime"].asInt64();
  113. //this->audioCode = root["audioCode"].asString();
  114. this->audioCode = "pcm8k16b";
  115. this->sentenceBeginTime = root["sentenceBeginTime"].asInt64();
  116. this->transSentenceText = root["transSentenceText"].asString();
  117. this->transSentenceIndex = root["transSentenceIndex"].asInt();
  118. this->transSentenceTime = root["transSentenceTime"].asInt64();
  119. }
  120. tagAsrInfo(std::string callId, std::string agentId, std::string calledId, std::string callerId, std::string direction, std::string vocDirect) {
  121. this->callId = callId;
  122. this->reference = "";
  123. this->agentId = agentId;
  124. this->calledId = calledId;
  125. this->callStartTime = 0;
  126. this->callerId = callerId;
  127. this->state = "";
  128. this->direction = direction;
  129. this->vocDirect = vocDirect;
  130. this->createTime = 0;
  131. this->audioCode = "";
  132. this->sentenceBeginTime = 0;
  133. this->transSentenceText = "";
  134. this->transSentenceIndex = 0;
  135. this->transSentenceTime = 0;
  136. }
  137. tagAsrInfo& operator>>(std::string& str) {
  138. Json::Value root;
  139. Json::StreamWriterBuilder builder;
  140. const std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
  141. root["callId"] = this->callId;
  142. root["reference"] = this->reference;
  143. root["agentId"] = this->agentId;
  144. root["calledId"] = this->calledId;
  145. root["callStartTime"] = this->callStartTime;
  146. root["callerId"] = this->callerId;
  147. root["state"] = this->state;
  148. root["direction"] = this->direction;
  149. root["vocDirect"] = this->vocDirect;
  150. root["createTime"] = this->createTime;
  151. root["audioCode"] = this->audioCode;
  152. root["sentenceBeginTime"] = this->sentenceBeginTime;
  153. root["transSentenceText"] = this->transSentenceText;
  154. root["transSentenceIndex"] = this->transSentenceIndex;
  155. root["transSentenceTime"] = this->transSentenceTime;
  156. str = Json::writeString(builder, root);
  157. return *this;
  158. }
  159. tagAsrInfo& operator<<(const char* str) {
  160. JSONCPP_STRING err;
  161. Json::Value root;
  162. Json::CharReaderBuilder builder;
  163. const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
  164. if (!reader->parse(str, str + strlen(str), &root, &err))
  165. {
  166. return *this;
  167. }
  168. this->callId = root["callId"].asString();
  169. this->reference = root["reference"].asString();
  170. this->agentId = root["agentId"].asString();
  171. this->calledId = root["calledId"].asString();
  172. this->callStartTime = root["callStartTime"].asInt64();
  173. this->callerId = root["callerId"].asString();
  174. //this->state = root["state"].asString();
  175. this->state = "calling";
  176. this->direction = root["direction"].asString();
  177. this->vocDirect = root["vocDirect"].asString();
  178. this->createTime = root["createTime"].asInt64();
  179. //this->audioCode = root["audioCode"].asString();
  180. this->audioCode = "pcm8k16b";
  181. this->sentenceBeginTime = root["sentenceBeginTime"].asInt64();
  182. this->transSentenceText = root["transSentenceText"].asString();
  183. this->transSentenceIndex = root["transSentenceIndex"].asInt();
  184. this->transSentenceTime = root["transSentenceTime"].asInt64();
  185. return *this;
  186. }
  187. tagAsrInfo& operator<<(std::string& str) {
  188. JSONCPP_STRING err;
  189. Json::Value root;
  190. Json::CharReaderBuilder builder;
  191. const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
  192. if (!reader->parse(str.c_str(), str.c_str() + str.length(), &root, &err))
  193. {
  194. return *this;
  195. }
  196. this->callId = root["callId"].asString();
  197. this->reference = root["reference"].asString();
  198. this->agentId = root["agentId"].asString();
  199. this->calledId = root["calledId"].asString();
  200. this->callStartTime = root["callStartTime"].asInt64();
  201. this->callerId = root["callerId"].asString();
  202. //this->state = root["state"].asString();
  203. this->state = "calling";
  204. this->direction = root["direction"].asString();
  205. this->vocDirect = root["vocDirect"].asString();
  206. this->createTime = root["createTime"].asInt64();
  207. //this->audioCode = root["audioCode"].asString();
  208. this->audioCode = "pcm8k16b";
  209. this->sentenceBeginTime = root["sentenceBeginTime"].asInt64();
  210. this->transSentenceText = root["transSentenceText"].asString();
  211. this->transSentenceIndex = root["transSentenceIndex"].asInt();
  212. this->transSentenceTime = root["transSentenceTime"].asInt64();
  213. return *this;
  214. }
  215. tagAsrInfo& operator=(const tagAsrInfo& a) {
  216. this->callId = a.callId;
  217. this->reference = a.reference;
  218. this->agentId = a.agentId;
  219. this->calledId = a.calledId;
  220. this->callStartTime = a.callStartTime;
  221. this->callerId = a.callerId;
  222. this->state = a.state;
  223. this->direction = a.direction;
  224. this->vocDirect = a.vocDirect;
  225. this->createTime = a.createTime;
  226. this->audioCode = a.audioCode;
  227. this->sentenceBeginTime = a.sentenceBeginTime;
  228. this->transSentenceText = a.transSentenceText;
  229. this->transSentenceIndex = a.transSentenceIndex;
  230. this->transSentenceTime = a.transSentenceTime;
  231. return *this;
  232. }
  233. }AsrInfo;
  234. //获取13位时间戳
  235. int64_t GetUnixTime();
  236. #ifdef _UNICODE
  237. #if defined _M_IX86
  238. #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
  239. #elif defined _M_X64
  240. #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
  241. #else
  242. #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
  243. #endif
  244. #endif