📄 wqmanager.cpp
字号:
/*=============================================================
Function:
Author: Leon Wang <wlywly@sina.com giga2@tom.com>
==============================================================*/
// WQManager.cpp: implementation of the WQManager class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "WQManager.h"
#include "acdconfig.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//##ModelId=424BB63F0162
int WQManager::KILL_SLEEP = 3;// sleep 3 sec after killing WQs, before unregister
//##ModelId=424BB63F0163
int WQManager::DEFAULT_PORTRANGE = 1730;// default for portrange start
//##ModelId=424BB63F015F
WQManager::WQManager()
{
}
//##ModelId=424BB63F0160
WQManager::~WQManager()
{
}
//##ModelId=424BB63F0150
unsigned __stdcall WQManager::_RUN(void *p)
{
WQManager * pThis = (WQManager*)p;
pThis->RUN();
delete pThis;
return 0;
}
/*
clear waiting queue threads
*/
//##ModelId=424BB63F0153
void WQManager::RUN()
{
// if have thread
if (!processList.empty()) {
Logger::log("Stopping talking wait queues");
// find all thread and destroy it
for(int i = 0; i < processList.size(); i++ ) {
//WQProcess wq = (WQProcess) processList[i];
//wq.p.destroy(); // terminates the process
}
//Thread.sleep(KILL_SLEEP * 1000); // wait 3 sec
// unregister alias from GK
for(int j = 0; j < processList.size(); j++ ) {
//WQProcess wq = (WQProcess) processList[i];
// send UnregisterAlias to GnuGk
//gk->unregisterAlias(wq.alias);
}
// clear all threads
processList.clear();
}
}
//##ModelId=424BB63F0141
void WQManager::startWaitQueues(GkClient _gk)
{
ACDConfig* config = ACDConfig::getInstance();
// maybe here is waiting queue parameter
CString startCmd = config->getConfigKey("Main","wq_start_cmd", "");
//int port = config->getConfigKey("wq_portrange_start", DEFAULT_PORTRANGE);
int port = config->getConfigKey("Main","wq_portrange_start", 1730);
gk = _gk;
if (startCmd.GetLength() <= 0)
return; // don't start talking agents
//????????????? need startwaitqueues function ?
// register a hook so we can clean up on shutdown
//Runtime.getRuntime().addShutdownHook(this);
/*
String[] queues = config.getQueues();
for (int q=0; q < queues.length; q++) {
String queue = queues[q];
int mode = config.getQueueingMode(queue);
if ((mode == ACDConfig.QUEUEING_MODE_TALKING) || (mode == ACDConfig.QUEUEING_MODE_RINGANDTALK)) {
int numAgents = config.getMaxSize(queue);
Logger.log("Starting " + numAgents + " talking wait queues for " + queue);
String messageFile = config.getConfigKey(queue + "_wq_message", "");
for (int i=1; i <= numAgents; i++) {
String alias = queue + "_wq_" + i;
String execCmd = startCmd;
execCmd = execCmd.replaceAll("%P", new Integer(port).toString());
execCmd = execCmd.replaceAll("%A", alias);
execCmd = execCmd.replaceAll("%W", messageFile);
try {
Logger.debug("Forking " + execCmd);
Process p = Runtime.getRuntime().exec(execCmd);
processList.add(new WQProcess(alias, p));
// // DEBUG: catch STDOUT from new process
// BufferedReader is = new BufferedReader(new InputStreamReader(p.getInputStream()));
// String line;
// while ((line = is.readLine()) != null)
// System.out.println(line);
} catch (IOException e) {
Logger.log("Start of " + alias + " failed.");
}
// increment listenport
port++;
}
}
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -