Explorar el Código

通话记录添加组groups字段,置忙置闲状态发送到监控

baiwenju %!s(int64=5) %!d(string=hace) años
padre
commit
34afff196c

+ 1 - 0
FreeSWITCH-linux/Agent.cpp

24
 	m_ReposeNum = 0;
24
 	m_ReposeNum = 0;
25
 	m_AnswerNum = 0;
25
 	m_AnswerNum = 0;
26
 	m_Groups.clear();
26
 	m_Groups.clear();
27
+	m_Group = a_Group;
27
 	boost::split(m_Groups, a_Group, boost::is_any_of("|"));
28
 	boost::split(m_Groups, a_Group, boost::is_any_of("|"));
28
 	__login();
29
 	__login();
29
 }
30
 }

+ 3 - 2
FreeSWITCH-linux/Agent.h

43
 	websocketpp::connection_hdl& hdl() { return m_hdl; }
43
 	websocketpp::connection_hdl& hdl() { return m_hdl; }
44
 
44
 
45
 	std::list<std::string> groups() const { return m_Groups; };
45
 	std::list<std::string> groups() const { return m_Groups; };
46
-
46
+	std::string group() const { return m_Group; };
47
 private:
47
 private:
48
 	bool __login();
48
 	bool __login();
49
 	bool __logout();
49
 	bool __logout();
70
 	uint32_t	m_AnswerNum;				// 应答次数
70
 	uint32_t	m_AnswerNum;				// 应答次数
71
 	uint32_t	m_LogoutType;				// 签出类型 
71
 	uint32_t	m_LogoutType;				// 签出类型 
72
 
72
 
73
-	std::list<std::string> m_Groups;        // 坐席组
73
+	std::list<std::string> m_Groups;        // 坐席组,分割后
74
+	std::string m_Group;  // 坐席组,未分割
74
 
75
 
75
 	websocketpp::connection_hdl m_hdl;
76
 	websocketpp::connection_hdl m_hdl;
76
 };
77
 };

+ 11 - 3
FreeSWITCH-linux/EslGateway.cpp

373
 		regex reg("\\d+");
373
 		regex reg("\\d+");
374
 		if (!regex_match(HeaderValue, reg))
374
 		if (!regex_match(HeaderValue, reg))
375
 		{
375
 		{
376
-		//	HeaderValue = esl_event_get_header(pEvent, "variable_dialed_user");  //判断被叫号码是不是软电话,软电话获取的被叫不是真实注册的分机号,是随机字符串
376
+			LOG_WARN("被叫号码为非存数字,软电话可能需要处理,分机号: %s", HeaderValue);
377
+			HeaderValue = esl_event_get_header(pEvent, "variable_dialed_user");  //判断被叫号码是不是软电话,软电话获取的被叫不是真实注册的分机号,是随机字符串
377
 			LOG_WARN("被叫号码为非存数字,软电话可能需要处理,分机号: %s", HeaderValue);
378
 			LOG_WARN("被叫号码为非存数字,软电话可能需要处理,分机号: %s", HeaderValue);
378
 		}
379
 		}
379
 		Notify.Callee = HeaderValue;
380
 		Notify.Callee = HeaderValue;
401
 		Notify.TaskId = atol(HeaderValue);
402
 		Notify.TaskId = atol(HeaderValue);
402
 	}
403
 	}
403
 
404
 
405
+	// 代码外呼,自动外呼时,主叫create事件时就得到正确的被叫
406
+	HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_CHAN_MALL_CALL_CALLEE);
407
+	if (HeaderValue != nullptr)
408
+	{
409
+		LOG_DEBUG("%s=%s", ESL_HEADER_CHAN_MALL_CALL_CALLEE, HeaderValue);
410
+		Notify.Called = HeaderValue;
411
+	}
404
 	
412
 	
405
 	// 获取挂机原因
413
 	// 获取挂机原因
406
 	HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_HANGUP_CAUSE);
414
 	HeaderValue = esl_event_get_header(pEvent, ESL_HEADER_HANGUP_CAUSE);
421
 		Notify.ChanOpInstance = atol(HeaderValue);
429
 		Notify.ChanOpInstance = atol(HeaderValue);
422
 	}
430
 	}
423
 
431
 
424
-	Format fmt("FreeSWITCH事件,EventId = %d ,CallId =  %s,ChanId = %s,Direction = %d ,caller = %s,callee = %s , op_type = %d,op_instance = %ld,task_id = %ld");
425
-	fmt %Notify.EventId % Notify.CallId % Notify.ChanId % Notify.Direction % Notify.Caller % Notify.Callee % Notify.CallType % Notify.ChanOpInstance %Notify.TaskId;
432
+	Format fmt("FreeSWITCH事件,EventId = %d ,CallId =  %s,ChanId = %s,Direction = %d ,caller = %s,callee = %s , op_type = %d,op_instance = %ld,task_id = %ld,call_called = %s");
433
+	fmt %Notify.EventId % Notify.CallId % Notify.ChanId % Notify.Direction % Notify.Caller % Notify.Callee % Notify.CallType % Notify.ChanOpInstance %Notify.TaskId %Notify.Called;
426
 	LOG_DEBUG(fmt.str());
434
 	LOG_DEBUG(fmt.str());
427
 
435
 
428
 	m_pParent->onEslEvtChannel(&Notify);
436
 	m_pParent->onEslEvtChannel(&Notify);

+ 4 - 1
FreeSWITCH-linux/FsLinkInc.h

47
 #define ESL_VAR_OP_INSTANCE					"op_instance"
47
 #define ESL_VAR_OP_INSTANCE					"op_instance"
48
 #define ESL_VAR_DTMF_KEY					"dtmf_key"
48
 #define ESL_VAR_DTMF_KEY					"dtmf_key"
49
 #define ESL_VAR_OP_TYPE					    "op_type"      // 主要用于区分是否是自动外呼  操作类型
49
 #define ESL_VAR_OP_TYPE					    "op_type"      // 主要用于区分是否是自动外呼  操作类型
50
-#define ESL_VAR_TASK_ID					    "task_id"     // 任务id  自动外呼
50
+#define ESL_VAR_TASK_ID					    "task_id"      // 任务id  自动外呼
51
+#define ESL_VAR_MALL_CALL_CALLEE             "call_called" // 代码呼叫时,create事件得到正确的被叫号码
51
 
52
 
52
 // ESL事件头域
53
 // ESL事件头域
53
 #define ESL_HEADER_CHAN_UNIQUE_ID			"Caller-Unique-ID"
54
 #define ESL_HEADER_CHAN_UNIQUE_ID			"Caller-Unique-ID"
70
 #define ESL_HEADER_CHAN_OP_INSTANCE			"variable_op_instance"
71
 #define ESL_HEADER_CHAN_OP_INSTANCE			"variable_op_instance"
71
 #define ESL_HEADER_CHAN_OP_TYPE			    "variable_op_type"   // 操作类型  自动外呼
72
 #define ESL_HEADER_CHAN_OP_TYPE			    "variable_op_type"   // 操作类型  自动外呼
72
 #define ESL_HEADER_CHAN_TASK_ID			    "variable_task_id"   // 任务id  自动外呼
73
 #define ESL_HEADER_CHAN_TASK_ID			    "variable_task_id"   // 任务id  自动外呼
74
+#define ESL_HEADER_CHAN_MALL_CALL_CALLEE    "variable_call_called" // 代码呼叫时,create事件得到正确的被叫号码
73
 #define ESL_HEADER_DTMF						"DTMF-Digit"
75
 #define ESL_HEADER_DTMF						"DTMF-Digit"
74
 
76
 
75
 // ESL事件头域常量值
77
 // ESL事件头域常量值
164
 	long ChanOpInstance = 0l;
166
 	long ChanOpInstance = 0l;
165
 	int CallType =0;      // 自动外呼时赋值
167
 	int CallType =0;      // 自动外呼时赋值
166
 	long TaskId = 0l;     // 自动外呼任务id
168
 	long TaskId = 0l;     // 自动外呼任务id
169
+	string Called;        // 保存代码外呼时,被叫,用于来电显示
167
 } CHAN_EVENT_NOTIFY, *PCHAN_EVENT_NOTIFY;
170
 } CHAN_EVENT_NOTIFY, *PCHAN_EVENT_NOTIFY;
168
 
171
 
169
 // 放音收号内容
172
 // 放音收号内容

+ 60 - 4
FreeSWITCH-linux/FsProxy.cpp

279
 
279
 
280
 void CFsProxy::onEslExtenUnreg(uint32_t ExtenNo)
280
 void CFsProxy::onEslExtenUnreg(uint32_t ExtenNo)
281
 {
281
 {
282
+	std::string agentId;
282
 	{
283
 	{
283
 		std::unique_lock<std::mutex>lock(m_AgentLock);
284
 		std::unique_lock<std::mutex>lock(m_AgentLock);
284
 		auto it = m_MapAgent.find(std::to_string(ExtenNo));
285
 		auto it = m_MapAgent.find(std::to_string(ExtenNo));
285
 		if (it != m_MapAgent.end())
286
 		if (it != m_MapAgent.end())
286
 		{
287
 		{
288
+			agentId = it->second->id();
287
 			it->second->removeAgent("分机掉线");
289
 			it->second->removeAgent("分机掉线");
288
 			//m_Gateway.delAgent(it->second->id());   // callcenter模块中删除
290
 			//m_Gateway.delAgent(it->second->id());   // callcenter模块中删除
289
 			m_Gateway.delAgent(it->second->id(), it->second->groups());
291
 			m_Gateway.delAgent(it->second->id(), it->second->groups());
291
 			m_MapAgent.erase(it);                   // 从签入列表中删除
293
 			m_MapAgent.erase(it);                   // 从签入列表中删除
292
 		}
294
 		}
293
 	}
295
 	}
296
+
297
+	if (!agentId.empty())
298
+	{
299
+		std::string data = creatJson("Monitor", "签出", agentId);
300
+		m_MonitAgents.loopAgent(m_Server, data);  // 通知班长坐席监控
301
+	}
302
+
294
 	__delExten(ExtenNo);
303
 	__delExten(ExtenNo);
295
 }
304
 }
296
 
305
 
416
 	return it->second->id();
425
 	return it->second->id();
417
 }
426
 }
418
 
427
 
428
+std::string CFsProxy::getAgentByExten(std::string ExtenNo, std::string &Groups)
429
+{
430
+	std::unique_lock<std::mutex>lock(m_AgentLock);
431
+	auto it = m_MapAgent.find(ExtenNo);
432
+	if (it->second == nullptr) return "";
433
+	Groups = it->second->group();
434
+	return it->second->id();
435
+}
436
+
419
 std::string CFsProxy::getExtenByAgent(std::string AgentId)
437
 std::string CFsProxy::getExtenByAgent(std::string AgentId)
420
 {
438
 {
421
 	std::unique_lock<std::mutex>lock(m_AgentLock);
439
 	std::unique_lock<std::mutex>lock(m_AgentLock);
431
 
449
 
432
 bool CFsProxy::ExtenCall(long JobId, VirtualChan * pChan, std::string CallerNum, std::string CalleeNum)
450
 bool CFsProxy::ExtenCall(long JobId, VirtualChan * pChan, std::string CallerNum, std::string CalleeNum)
433
 {
451
 {
434
-	Format fmt("bgapi originate {origination_caller_id_number=%lu}user/%lu %s XML %s\r\n%s: %ld");
435
-	fmt % pChan->no() % pChan->no() % CalleeNum % CConfig::GetInstance()->extContext() % ESL_HEADER_JOB_UUID % JobId;
452
+	/*Format fmt("bgapi originate {origination_caller_id_number=%lu }user/%lu %s XML %s\r\n%s: %ld");
453
+	fmt % pChan->no() % pChan->no() % CalleeNum % CConfig::GetInstance()->extContext() % ESL_HEADER_JOB_UUID % JobId;*/
454
+	
455
+	std::string called;
456
+	if (getExten(atoi(CalleeNum.c_str())) == nullptr)
457
+	{
458
+		std::string prefix = CConfig::GetInstance()->gateWayPrefix();
459
+		called = CalleeNum.substr(prefix.length(), CalleeNum.length()- prefix.length());
460
+	}
461
+	else
462
+	{
463
+		called = CalleeNum;
464
+	}
465
+	Format fmt("bgapi originate {origination_caller_id_number=%lu,%s=%s}user/%lu %s XML %s\r\n%s: %ld");
466
+	fmt % pChan->no() % ESL_VAR_MALL_CALL_CALLEE %called % pChan->no() % CalleeNum % CConfig::GetInstance()->extContext() % ESL_HEADER_JOB_UUID % JobId;
467
+
436
 	return m_Gateway.sendCmd(fmt.str());
468
 	return m_Gateway.sendCmd(fmt.str());
437
 }
469
 }
438
 bool CFsProxy::PredictionCall(long JobId, std::string CallerNum, std::string CalleeNum)
470
 bool CFsProxy::PredictionCall(long JobId, std::string CallerNum, std::string CalleeNum)
453
 	if (!m_CallStringMaker.makeCallString(Caller, CallerNum, CallString))
485
 	if (!m_CallStringMaker.makeCallString(Caller, CallerNum, CallString))
454
 		return false;
486
 		return false;
455
 	std::string EslCmd;
487
 	std::string EslCmd;
456
-	EslCmd = boost::str(Format("bgapi originate {origination_caller_id_number=%s,%s=%ld,%s=%ld}%s %s XML %s\r\n%s: %ld")
457
-		% CallerNum % ESL_VAR_OP_TYPE % OpType % ESL_VAR_TASK_ID % TaskId % CallString % CalleeNum % CConfig::GetInstance()->extContext() % ESL_HEADER_JOB_UUID % JobId);
488
+	/*EslCmd = boost::str(Format("bgapi originate {origination_caller_id_number=%s,%s=%ld,%s=%ld}%s %s XML %s\r\n%s: %ld")
489
+		% CallerNum % ESL_VAR_OP_TYPE % OpType % ESL_VAR_TASK_ID % TaskId % CallString % CalleeNum % CConfig::GetInstance()->extContext() % ESL_HEADER_JOB_UUID % JobId);*/
490
+
491
+	std::string called;
492
+	if (getExten(atoi(CalleeNum.c_str())) == nullptr)
493
+	{
494
+		std::string prefix = CConfig::GetInstance()->gateWayPrefix();
495
+		called = CalleeNum.substr(prefix.length(), CalleeNum.length() - prefix.length());
496
+	}
497
+	else
498
+	{
499
+		called = CalleeNum;
500
+	}
501
+	EslCmd = boost::str(Format("bgapi originate {origination_caller_id_number=%s,%s=%ld,%s=%ld,,%s=%s}%s %s XML %s\r\n%s: %ld")
502
+		% CallerNum % ESL_VAR_OP_TYPE % OpType % ESL_VAR_TASK_ID % TaskId % ESL_VAR_MALL_CALL_CALLEE %called % CallString % CalleeNum % CConfig::GetInstance()->extContext() % ESL_HEADER_JOB_UUID % JobId);
458
 
503
 
459
 	return m_Gateway.sendCmd(EslCmd);
504
 	return m_Gateway.sendCmd(EslCmd);
460
 }
505
 }
1093
 		fmt %ret % AgentID % AgentExten % hdl.lock().get();
1138
 		fmt %ret % AgentID % AgentExten % hdl.lock().get();
1094
 		LOG_INFO_S(fmt.str());
1139
 		LOG_INFO_S(fmt.str());
1095
 		m_Server.sendMsg(hdl, creatJson(type, ret));
1140
 		m_Server.sendMsg(hdl, creatJson(type, ret));
1141
+
1142
+		std::string data = creatJson("Monitor", "签出", AgentID);
1143
+		m_MonitAgents.loopAgent(m_Server, data);  // 通知班长坐席监控
1096
 	}
1144
 	}
1097
 	else if ("SayBusy" == type) {   // 置忙
1145
 	else if ("SayBusy" == type) {   // 置忙
1098
 		bool ret = __setState(AgentID, false);
1146
 		bool ret = __setState(AgentID, false);
1101
 		if (it != m_MapAgent.end())
1149
 		if (it != m_MapAgent.end())
1102
 			it->second->setState(AGENT_STATE_REPOSE);
1150
 			it->second->setState(AGENT_STATE_REPOSE);
1103
 		m_Server.sendMsg(hdl, creatJson(type, ret));
1151
 		m_Server.sendMsg(hdl, creatJson(type, ret));
1152
+
1153
+		std::string data = creatJson("Monitor", "小休", AgentID);
1154
+		m_MonitAgents.loopAgent(m_Server, data);  // 通知班长坐席监控
1104
 	}
1155
 	}
1105
 	else if ("SayFree" == type) {   // 置闲
1156
 	else if ("SayFree" == type) {   // 置闲
1106
 		bool ret = __setState(AgentID, true);
1157
 		bool ret = __setState(AgentID, true);
1109
 		if (it != m_MapAgent.end())
1160
 		if (it != m_MapAgent.end())
1110
 			it->second->setState(AGENT_STATE_FREE);
1161
 			it->second->setState(AGENT_STATE_FREE);
1111
 		m_Server.sendMsg(hdl, creatJson(type, ret));
1162
 		m_Server.sendMsg(hdl, creatJson(type, ret));
1163
+
1164
+		std::string data = creatJson("Monitor", "空闲", AgentID);
1165
+		m_MonitAgents.loopAgent(m_Server, data);  // 通知班长坐席监控
1112
 	}
1166
 	}
1113
 	else if ("Hold" == type) {   // 保持
1167
 	else if ("Hold" == type) {   // 保持
1114
 		bool ret = COperationReactor::GetInstance()->procOperation(opInstance++, LINE_OP_HOLD, ExtenNo, nullptr);
1168
 		bool ret = COperationReactor::GetInstance()->procOperation(opInstance++, LINE_OP_HOLD, ExtenNo, nullptr);
1287
 
1341
 
1288
 	if (!agentId.empty())
1342
 	if (!agentId.empty())
1289
 	{
1343
 	{
1344
+		std::string data = creatJson("Monitor", "签出", agentId);
1345
+		m_MonitAgents.loopAgent(m_Server, data);  // 通知班长坐席监控
1290
 		m_MonitAgents.delAgent(agentId);
1346
 		m_MonitAgents.delAgent(agentId);
1291
 	}
1347
 	}
1292
 }
1348
 }

+ 1 - 0
FreeSWITCH-linux/FsProxy.h

83
 	void regBusyChan(VirtualChan* pChan);
83
 	void regBusyChan(VirtualChan* pChan);
84
 	void unregBusyChan(VirtualChan* pChan);
84
 	void unregBusyChan(VirtualChan* pChan);
85
 	std::string getAgentByExten(std::string ExtenNo);
85
 	std::string getAgentByExten(std::string ExtenNo);
86
+	std::string getAgentByExten(std::string ExtenNo, std::string &Groups);
86
 	std::string getExtenByAgent(std::string AgentId);
87
 	std::string getExtenByAgent(std::string AgentId);
87
 	Session* getSession(string SessionId) { return __getSession( SessionId); };
88
 	Session* getSession(string SessionId) { return __getSession( SessionId); };
88
 
89
 

+ 32 - 8
FreeSWITCH-linux/Session.cpp

212
 			std::string ExtenNo = std::to_string(pChanHost->no());
212
 			std::string ExtenNo = std::to_string(pChanHost->no());
213
 			std::string Number = pNotify->Caller;  // 主叫号码
213
 			std::string Number = pNotify->Caller;  // 主叫号码
214
 			std::string callee = pNotify->Callee;  // 被叫号码
214
 			std::string callee = pNotify->Callee;  // 被叫号码
215
+			
216
+			if (Number == callee && !pNotify->Called.empty())
217
+			{
218
+				callee = pNotify->Called;
219
+			}
220
+			
215
 			std::string TrunkNumber;
221
 			std::string TrunkNumber;
216
 			int inComingType = 0;
222
 			int inComingType = 0;
217
 			if (pNotify->CallType == 0) // 分机外呼
223
 			if (pNotify->CallType == 0) // 分机外呼
323
 		std::string curTime = Util::CurTime();
329
 		std::string curTime = Util::CurTime();
324
 		std::string agent;
330
 		std::string agent;
325
 		std::string callee;  // 被叫
331
 		std::string callee;  // 被叫
326
-
332
+		std::string group;  // 坐席组
327
 		if (pChanHost->type() == DEV_RES_TYPE_TRUNK && pChanHost == __getFirstChan()) // 中继呼入且先挂机
333
 		if (pChanHost->type() == DEV_RES_TYPE_TRUNK && pChanHost == __getFirstChan()) // 中继呼入且先挂机
328
 		{
334
 		{
329
 			auto pAssoChan = getAssoChan(pChanHost);   // 根据对端线路获取被叫
335
 			auto pAssoChan = getAssoChan(pChanHost);   // 根据对端线路获取被叫
339
 			else
345
 			else
340
 				callee = pNotify->Callee;
346
 				callee = pNotify->Callee;
341
 		}
347
 		}
342
-		agent = m_pParent->getAgentByExten(callee);
348
+		agent = m_pParent->getAgentByExten(callee,group);
343
 		//std::string callid = pNotify->CcId.empty() == true ? pNotify->CallId : pNotify->CcId;   // 获取callid
349
 		//std::string callid = pNotify->CcId.empty() == true ? pNotify->CallId : pNotify->CcId;   // 获取callid
344
 
350
 
345
 		auto fun = [](std::string time)->std::string { if (time.empty()) return "null"; else return "'" + time + "'"; }; // 匿名函数用于转化时间
351
 		auto fun = [](std::string time)->std::string { if (time.empty()) return "null"; else return "'" + time + "'"; }; // 匿名函数用于转化时间
350
 			m_AtionId = 1;
356
 			m_AtionId = 1;
351
 		/*Format fmt("update cdr set callee_agent = '%s',callee = '%s', ring_time = %s,answer_time = %s,end_time = '%s',record_path = '%s', hangup_cause = '%s' where uuid = '%s' and action_id = %d");
357
 		/*Format fmt("update cdr set callee_agent = '%s',callee = '%s', ring_time = %s,answer_time = %s,end_time = '%s',record_path = '%s', hangup_cause = '%s' where uuid = '%s' and action_id = %d");
352
 		fmt %agent %callee % m_RingTime %m_AnswerTime %curTime %m_RecordFile %pNotify->HangupCause %pChanHost->sessionId() % m_AtionId;*/
358
 		fmt %agent %callee % m_RingTime %m_AnswerTime %curTime %m_RecordFile %pNotify->HangupCause %pChanHost->sessionId() % m_AtionId;*/
353
-		Format fmt("update cdr set callee_agent = '%s',callee = '%s', ring_time = %s,answer_time = %s,is_answer = %d,end_time = '%s',hangup_time = '%s',record_path = '%s', hangup_cause = '%s' where uuid = '%s' and action_id = %d");
354
-		fmt %agent %callee % m_RingTime %m_AnswerTime %m_IsAnswer %curTime %curTime %m_RecordFile %pNotify->HangupCause %pChanHost->sessionId() % m_AtionId;
359
+
360
+		/*Format fmt("update cdr set callee_agent = '%s',callee = '%s', ring_time = %s,answer_time = %s,is_answer = %d,end_time = '%s',hangup_time = '%s',record_path = '%s', hangup_cause = '%s' where uuid = '%s' and action_id = %d");
361
+		fmt %agent %callee % m_RingTime %m_AnswerTime %m_IsAnswer %curTime %curTime %m_RecordFile %pNotify->HangupCause %pChanHost->sessionId() % m_AtionId;*/
362
+
363
+		/*Format fmt("update cdr set callee_agent = '%s',callee = '%s', ring_time = %s,answer_time = %s,is_answer = %d,end_time = '%s',record_path = '%s', hangup_cause = '%s' where uuid = '%s' and action_id = %d");
364
+		fmt %agent %callee % m_RingTime %m_AnswerTime %m_IsAnswer %curTime %m_RecordFile %pNotify->HangupCause %pChanHost->sessionId() % m_AtionId;*/
365
+
366
+		// 增加被叫坐席组
367
+		Format fmt("update cdr set groups = '%s',callee_agent = '%s',callee = '%s', ring_time = %s,answer_time = %s,is_answer = %d,end_time = '%s',record_path = '%s', hangup_cause = '%s' where uuid = '%s' and action_id = %d");
368
+		fmt %group %agent %callee % m_RingTime %m_AnswerTime %m_IsAnswer %curTime %m_RecordFile %pNotify->HangupCause %pChanHost->sessionId() % m_AtionId;
355
 
369
 
356
 		SqlWrite::GetInstance()->addSql(fmt.str());
370
 		SqlWrite::GetInstance()->addSql(fmt.str());
357
 		// 清空
371
 		// 清空
360
 		m_IsAnswer = false;
374
 		m_IsAnswer = false;
361
 		m_IsSaveDb = false;
375
 		m_IsSaveDb = false;
362
 	}
376
 	}
377
+
378
+	if (pNotify->EventId == CHANNEL_EVENT_HANGUP_COMPLETE && pChanHost->type() == DEV_RES_TYPE_TRUNK)
379
+	{
380
+		std::string curTime = Util::CurTime();
381
+		Format fmt("update cdr set hangup_time = '%s' where uuid = '%s'");
382
+		fmt  %curTime %pChanHost->sessionId();
383
+		SqlWrite::GetInstance()->addSql(fmt.str());
384
+	}
363
 }
385
 }
364
 
386
 
365
 void Session::__saveAutoCallDB(VirtualChan * pChanHost, PCHAN_EVENT_NOTIFY pNotify)
387
 void Session::__saveAutoCallDB(VirtualChan * pChanHost, PCHAN_EVENT_NOTIFY pNotify)
421
 
443
 
422
 void Session::__onChanFree(VirtualChan * pChan, PCHAN_EVENT_NOTIFY pNotify)
444
 void Session::__onChanFree(VirtualChan * pChan, PCHAN_EVENT_NOTIFY pNotify)
423
 {
445
 {
424
-	if (m_Id == pNotify->ChanId)	// 若会话主通道空闲则清空会话
425
-		__clearChan();
426
-	else
427
-		__delChan(pChan);
446
+	//if (m_Id == pNotify->ChanId)	// 若会话主通道空闲则清空会话
447
+	//	__clearChan();
448
+	//else
449
+	//	__delChan(pChan);
450
+
451
+	__delChan(pChan);   // 防止重复收到挂机事件覆盖之前的有效数据
428
 
452
 
429
 	if (pChan->isVoid())		// 若通道已被丢弃,则删除
453
 	if (pChan->isVoid())		// 若通道已被丢弃,则删除
430
 		m_pParent->delChan(pChan);
454
 		m_pParent->delChan(pChan);

+ 5 - 0
FreeSWITCH-linux/SoftAuth.cpp

90
 	//	std::cout << "解密后:" << out << std::endl;
90
 	//	std::cout << "解密后:" << out << std::endl;
91
 		std::string machcode1;  // 机器码-本机
91
 		std::string machcode1;  // 机器码-本机
92
 		__getdiskid(machcode1);
92
 		__getdiskid(machcode1);
93
+		if (machcode1.empty())
94
+		{
95
+			std::cout << "机器码获取失败,请用root权限运行!" << std::endl;
96
+			return false;
97
+		}
93
 	//	std::cout << machcode1 << std::endl;
98
 	//	std::cout << machcode1 << std::endl;
94
 	//	std::string data = std::regex_replace(out, std::regex(machcode1), "");
99
 	//	std::string data = std::regex_replace(out, std::regex(machcode1), "");
95
 		std::string data = out.substr(machcode1.length(), out.length()- machcode1.length());
100
 		std::string data = out.substr(machcode1.length(), out.length()- machcode1.length());

BIN
FreeSWITCH-linux/bin/x64/Release/middleware


+ 5 - 1
FreeSWITCH-linux/main.cpp

52
 	{
52
 	{
53
 		std::cout << "该机器未授权,请授权后使用" << std::endl;
53
 		std::cout << "该机器未授权,请授权后使用" << std::endl;
54
 		std::string hardc;
54
 		std::string hardc;
55
-		SoftAuth::GetInstance()->getMachineCode(hardc);
55
+		if (!SoftAuth::GetInstance()->getMachineCode(hardc))
56
+		{
57
+			std::cout << "机器码获取失败,请用root权限运行!" << std::endl;
58
+			return 0;
59
+		}
56
 		std::cout << "机器码:" << hardc << std::endl;
60
 		std::cout << "机器码:" << hardc << std::endl;
57
 
61
 
58
 		std::string code;// = "MWEyZGZmYzctYTVjNC00OWEwLTgxNTgtMTQ3YjNmYTA3Zjc4CjIwMjAwNzE2";
62
 		std::string code;// = "MWEyZGZmYzctYTVjNC00OWEwLTgxNTgtMTQ3YjNmYTA3Zjc4CjIwMjAwNzE2";

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 9 - 9
FreeSWITCH-linux/obj/x64/Release/-2104221788.CompileUpToDateFile.tlog


+ 9 - 9
FreeSWITCH-linux/obj/x64/Release/-2104221788.CopySourcesUpToDateFile.tlog

1
-C:\Project\Middlewares-Linux\FreeSWITCH-linux\Agent.cpp|637322427291729188|~/projects/FreeSWITCH-linux|
1
+C:\Project\Middlewares-Linux\FreeSWITCH-linux\Agent.cpp|637335432254719930|~/projects/FreeSWITCH-linux|
2
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\AutoCall.cpp|637322441488183541|~/projects/FreeSWITCH-linux|
2
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\AutoCall.cpp|637322441488183541|~/projects/FreeSWITCH-linux|
3
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\CallStringMaker.cpp|637293000196977222|~/projects/FreeSWITCH-linux|
3
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\CallStringMaker.cpp|637293000196977222|~/projects/FreeSWITCH-linux|
4
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\ChanExten.cpp|637330189263917248|~/projects/FreeSWITCH-linux|
4
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\ChanExten.cpp|637330189263917248|~/projects/FreeSWITCH-linux|
7
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpAutoCall.cpp|637322436438179212|~/projects/FreeSWITCH-linux|
7
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpAutoCall.cpp|637322436438179212|~/projects/FreeSWITCH-linux|
8
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpHangup.cpp|637311162276998365|~/projects/FreeSWITCH-linux|
8
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpHangup.cpp|637311162276998365|~/projects/FreeSWITCH-linux|
9
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpHoldon.cpp|637305760263197326|~/projects/FreeSWITCH-linux|
9
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpHoldon.cpp|637305760263197326|~/projects/FreeSWITCH-linux|
10
-C:\Project\Middlewares-Linux\FreeSWITCH-linux\EslGateway.cpp|637322386778580805|~/projects/FreeSWITCH-linux|
11
-C:\Project\Middlewares-Linux\FreeSWITCH-linux\FsProxy.cpp|637330199046298042|~/projects/FreeSWITCH-linux|
10
+C:\Project\Middlewares-Linux\FreeSWITCH-linux\EslGateway.cpp|637334514525907719|~/projects/FreeSWITCH-linux|
11
+C:\Project\Middlewares-Linux\FreeSWITCH-linux\FsProxy.cpp|637335986620899893|~/projects/FreeSWITCH-linux|
12
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\ChanTrunk.cpp|637291981012635660|~/projects/FreeSWITCH-linux|
12
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\ChanTrunk.cpp|637291981012635660|~/projects/FreeSWITCH-linux|
13
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\JdbcHelper.cpp|637322251479454832|~/projects/FreeSWITCH-linux|
13
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\JdbcHelper.cpp|637322251479454832|~/projects/FreeSWITCH-linux|
14
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\Log.cpp|637280686304488048|~/projects/FreeSWITCH-linux|
14
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\Log.cpp|637280686304488048|~/projects/FreeSWITCH-linux|
15
-C:\Project\Middlewares-Linux\FreeSWITCH-linux\main.cpp|637324036872540293|~/projects/FreeSWITCH-linux|
15
+C:\Project\Middlewares-Linux\FreeSWITCH-linux\main.cpp|637332549988509717|~/projects/FreeSWITCH-linux|
16
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\Md5.cpp|637280998994034399|~/projects/FreeSWITCH-linux|
16
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\Md5.cpp|637280998994034399|~/projects/FreeSWITCH-linux|
17
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\Operation.cpp|637292164167520236|~/projects/FreeSWITCH-linux|
17
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\Operation.cpp|637292164167520236|~/projects/FreeSWITCH-linux|
18
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OperationReactor.cpp|637329944322173868|~/projects/FreeSWITCH-linux|
18
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OperationReactor.cpp|637329944322173868|~/projects/FreeSWITCH-linux|
26
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpMyd.cpp|637305201854065451|~/projects/FreeSWITCH-linux|
26
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpMyd.cpp|637305201854065451|~/projects/FreeSWITCH-linux|
27
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpRecord.cpp|637308341755624735|~/projects/FreeSWITCH-linux|
27
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpRecord.cpp|637308341755624735|~/projects/FreeSWITCH-linux|
28
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpTransfer.cpp|637305107133879856|~/projects/FreeSWITCH-linux|
28
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpTransfer.cpp|637305107133879856|~/projects/FreeSWITCH-linux|
29
-C:\Project\Middlewares-Linux\FreeSWITCH-linux\Session.cpp|637328505371091867|~/projects/FreeSWITCH-linux|
30
-C:\Project\Middlewares-Linux\FreeSWITCH-linux\SoftAuth.cpp|637327639653281420|~/projects/FreeSWITCH-linux|
29
+C:\Project\Middlewares-Linux\FreeSWITCH-linux\Session.cpp|637335998389255617|~/projects/FreeSWITCH-linux|
30
+C:\Project\Middlewares-Linux\FreeSWITCH-linux\SoftAuth.cpp|637332552682414763|~/projects/FreeSWITCH-linux|
31
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\SqlWrite.cpp|637298176092937654|~/projects/FreeSWITCH-linux|
31
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\SqlWrite.cpp|637298176092937654|~/projects/FreeSWITCH-linux|
32
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\TimeScheduler.cpp|637292236462926004|~/projects/FreeSWITCH-linux|
32
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\TimeScheduler.cpp|637292236462926004|~/projects/FreeSWITCH-linux|
33
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\TtsBaidu.cpp|637312070891685050|~/projects/FreeSWITCH-linux|
33
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\TtsBaidu.cpp|637312070891685050|~/projects/FreeSWITCH-linux|
34
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\Util.cpp|637304067062022269|~/projects/FreeSWITCH-linux|
34
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\Util.cpp|637304067062022269|~/projects/FreeSWITCH-linux|
35
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\VirtualChan.cpp|637281766727680022|~/projects/FreeSWITCH-linux|
35
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\VirtualChan.cpp|637281766727680022|~/projects/FreeSWITCH-linux|
36
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\WebSocketServer.cpp|637292072391081855|~/projects/FreeSWITCH-linux|
36
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\WebSocketServer.cpp|637292072391081855|~/projects/FreeSWITCH-linux|
37
-C:\Project\Middlewares-Linux\FreeSWITCH-linux\Agent.h|637305787961834473|~/projects/FreeSWITCH-linux|
37
+C:\Project\Middlewares-Linux\FreeSWITCH-linux\Agent.h|637335431800839556|~/projects/FreeSWITCH-linux|
38
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\AutoCall.h|637321336072060353|~/projects/FreeSWITCH-linux|
38
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\AutoCall.h|637321336072060353|~/projects/FreeSWITCH-linux|
39
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\CalllDetaillnc.h|637293918120798402|~/projects/FreeSWITCH-linux|
39
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\CalllDetaillnc.h|637293918120798402|~/projects/FreeSWITCH-linux|
40
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\CallStringMaker.h|637290320107726902|~/projects/FreeSWITCH-linux|
40
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\CallStringMaker.h|637290320107726902|~/projects/FreeSWITCH-linux|
47
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpHoldon.h|637297127792923844|~/projects/FreeSWITCH-linux|
47
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\OpHoldon.h|637297127792923844|~/projects/FreeSWITCH-linux|
48
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\DevInfoInc.h|637322224857093737|~/projects/FreeSWITCH-linux|
48
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\DevInfoInc.h|637322224857093737|~/projects/FreeSWITCH-linux|
49
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\EslGateway.h|637302569365666270|~/projects/FreeSWITCH-linux|
49
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\EslGateway.h|637302569365666270|~/projects/FreeSWITCH-linux|
50
-C:\Project\Middlewares-Linux\FreeSWITCH-linux\FsLinkInc.h|637321386677343446|~/projects/FreeSWITCH-linux|
51
-C:\Project\Middlewares-Linux\FreeSWITCH-linux\FsProxy.h|637321390960653167|~/projects/FreeSWITCH-linux|
50
+C:\Project\Middlewares-Linux\FreeSWITCH-linux\FsLinkInc.h|637330227620371739|~/projects/FreeSWITCH-linux|
51
+C:\Project\Middlewares-Linux\FreeSWITCH-linux\FsProxy.h|637335438168678974|~/projects/FreeSWITCH-linux|
52
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\ChanTrunk.h|637285089118153659|~/projects/FreeSWITCH-linux|
52
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\ChanTrunk.h|637285089118153659|~/projects/FreeSWITCH-linux|
53
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\ITimer.h|637292236462776046|~/projects/FreeSWITCH-linux|
53
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\ITimer.h|637292236462776046|~/projects/FreeSWITCH-linux|
54
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\JdbcHelper.h|637302607605093273|~/projects/FreeSWITCH-linux|
54
 C:\Project\Middlewares-Linux\FreeSWITCH-linux\JdbcHelper.h|637302607605093273|~/projects/FreeSWITCH-linux|

+ 1 - 2
FreeSWITCH-linux/obj/x64/Release/FreeSWITCH-linux.log

3
   Validating architecture
3
   Validating architecture
4
   Starting remote build
4
   Starting remote build
5
   Compiling sources:
5
   Compiling sources:
6
-  FsProxy.cpp
7
-C:\Project\Middlewares-Linux\FreeSWITCH-linux\FsProxy.cpp(1040,41): warning : comparison between signed and unsigned integer expressions [-Wsign-compare]
6
+  Session.cpp
8
   Linking objects
7
   Linking objects
9
   FreeSWITCH-linux.vcxproj -> C:\Project\Middlewares-Linux\FreeSWITCH-linux\bin\x64\Release\middleware
8
   FreeSWITCH-linux.vcxproj -> C:\Project\Middlewares-Linux\FreeSWITCH-linux\bin\x64\Release\middleware