123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /*
- * BusinessConfig.cpp
- *
- * Created on: 2022年10月18日
- * Author: Allen
- */
- #include "BusinessConfig.h"
- #include "base/strings.hpp"
- CallingStatus::CallingStatus() {
- _busy = false;
- }
- CallingStatus::~CallingStatus() {
- }
- CallingStatus* CallingStatus::instance() {
- static CallingStatus singleton;
- return &singleton;
- }
- void CallingStatus::setBusy(bool busy){
- _busy = busy;
- }
- void CallingStatus::setTcpModel(TcpModel tcpModel){
- _tcpModel = tcpModel;
- }
- void CallingStatus::clearTcpModel(){
- _tcpModel.type = "";
- _tcpModel.action = "";
- _tcpModel.from_id = 0;
- _tcpModel.to_id = 0;
- _tcpModel.json = NULL;
- _tcpModel.data = "";
- }
- TcpModel CallingStatus::getTcpModel(){
- return _tcpModel;
- }
- long CallingStatus::getInteractionId(){
- if (_tcpModel.json > 0){
- if (_tcpModel.json.isMember("id")){
- return _tcpModel.json["id"].asInt();
- }
- }
- return 0;
- }
- bool CallingStatus::busy() {
- return instance()->_busy;
- }
- TcpCacheManager::TcpCacheManager() {
- }
- TcpCacheManager::~TcpCacheManager() {
- }
- TcpCacheManager* TcpCacheManager::instance() {
- static TcpCacheManager singleton;
- return &singleton;
- }
- void TcpCacheManager::setFunc(const std::string tid, TcpCallback callback){
- TcpCacheManager::cb.insert(std::map<std::string, TcpCallback>::value_type(tid, callback));
- }
- TcpCallback TcpCacheManager::getFunc(const std::string tid){
- std::map<std::string, TcpCallback>::iterator it;
- it = TcpCacheManager::cb.find(tid);
- TcpCallback callback;
- if (it != TcpCacheManager::cb.end()){
- callback = it->second;
- TcpCacheManager::cb.erase(tid);
- return callback;
- }
- callback.tid = "0";
- return callback;
- }
|