⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pendingrequest.cpp

📁 一个c++实现的acd的例子。 ----ACDCommandListener.cpp ---ACDCommandListenerThread.cpp ---ACDConfig.cpp ---a
💻 CPP
字号:
 /*=============================================================

 
 Function:
		


 Author: Leon Wang <wlywly@sina.com  giga2@tom.com>
==============================================================*/
// PendingRequest.cpp: implementation of the PendingRequest class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "PendingRequest.h"
#include "sha1.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//##ModelId=424BB6430101
int PendingRequest::RINGING = 1;
//##ModelId=424BB6430102
int PendingRequest::TALKING = 2;


//##ModelId=424BB64300C3
PendingRequest::PendingRequest()
{

}
    /**
     * Create a new request object.
     * @param _priority
     * @param _queue
     * @param _callerEndId
     * @param _callRef
     * @param _callerAlias
     * @param _callerIp
     * @param _timeout
     * @param _status   Ringing / Talking
     */
//##ModelId=424BB64300C4
PendingRequest::PendingRequest(int _priority, 
									  CString _queue, 
									  CString _callerEndId, 
									  CString _callRef, 
									  CString _callerAlias, 
									  CString _callerIp, 
									  long _timeout, 
									  int _status) 
{
        priority = _priority;
        queue = _queue;
        callerEndId = _callerEndId;
        callRef = _callRef;
        callerAlias = _callerAlias;
        callerIp = _callerIp;
        timeout = _timeout;
        status = _status;
}

//##ModelId=424BB64300E2
PendingRequest::~PendingRequest()
{

}
    /**
     * Sort requests by queue priority and expire time.
     * @param o     Object to compare to
     * @return      -1 / 0 / 1
     */
//##ModelId=424BB64300E4
int PendingRequest::compareTo(PendingRequest obj) 
{
        PendingRequest r2 = obj;
        if (priority < r2.priority)
            return 1;
        if (priority > r2.priority)
            return -1;
        if (timeout < r2.timeout)
            return -1;
        if (timeout > r2.timeout)
            return 1;
        if (callerEndId.Compare(r2.callerEndId) < 0)
            return -1;
        if (callerEndId.Compare(r2.callerEndId) > 0)
            return 1;
        return callRef.Compare(r2.callRef);
}

 /**
     * Requests are equal if endpoint ID and callRef match.
     * @param o Object to compare to
     * @return  T / F
     */
//##ModelId=424BB64300E6
BOOL PendingRequest::equals(PendingRequest obj) 
{
       PendingRequest r2 = obj;
       return (callerEndId==r2.callerEndId && callRef==r2.callRef);
}

    /**
     * Implement hashCode, based on what makes the object uniqe.
     * @return  hash code
     */
//##ModelId=424BB64300F3
void PendingRequest::hashCode(CString & hashString) 
{
	hashString = callerEndId + callRef;
	
	LPTSTR p = hashString.GetBuffer(hashString.GetLength());
	SHA1HashCode(p);// care it !! test it
	hashString = p;
	hashString.ReleaseBuffer();
   // return (callerEndId + callRef).hashCode();
}

//##ModelId=424BB64300F5
void PendingRequest::SHA1HashCode(char* &str)
{
	CSHA1 sha1;
	sha1.Reset();
	sha1.Update((UINT_8 *)str, strlen(str));
	sha1.Final();

	sha1.ReportHash(str, CSHA1::REPORT_DIGIT);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -