in nlsCppSdk/transport/connectNode.cpp [2582:2656]
void ConnectNode::handlerEvent(const char *errorMsg, int errorCode,
NlsEvent::EventType eventType, bool ignore) {
LOG_DEBUG("Node(%p) 's exit status:%s, eventType:%d.", this,
getExitStatusString().c_str(), eventType);
if (_exitStatus == ExitCancel) {
LOG_WARN("Node(%p) invoke cancel command, callback won't be invoked.",
this);
return;
}
if (_request == NULL) {
LOG_ERROR("The request of this node(%p) is nullptr.", this);
return;
}
if (errorCode != CloseCode) {
_nodeErrCode = errorCode;
}
std::string error_str(errorMsg);
if (error_str.empty()) {
LOG_WARN("Node(%p) errorMsg is empty!", this);
}
#ifdef ENABLE_REQUEST_RECORDING
if (eventType == NlsEvent::Close || eventType == NlsEvent::TaskFailed) {
if (eventType == NlsEvent::TaskFailed) {
_nodeProcess.last_op_timestamp_ms = utility::TextUtils::GetTimestampMs();
_nodeProcess.failed_timestamp_ms = _nodeProcess.last_op_timestamp_ms;
} else if (eventType == NlsEvent::Close) {
_nodeProcess.last_op_timestamp_ms = utility::TextUtils::GetTimestampMs();
_nodeProcess.closed_timestamp_ms = _nodeProcess.last_op_timestamp_ms;
}
error_str.assign(replenishNodeProcess(errorMsg));
if (eventType == NlsEvent::TaskFailed) {
LOG_ERROR("Node(%p) trigger message: %s", this, error_str.c_str());
} else if (eventType == NlsEvent::Close) {
LOG_INFO("Node(%p) trigger message: %s", this, error_str.c_str());
}
}
#endif
NlsEvent *useEvent = NULL;
useEvent = new NlsEvent(error_str.c_str(), errorCode, eventType,
_request->getRequestParam()->_task_id);
if (useEvent == NULL) {
LOG_ERROR("Node(%p) new NlsEvent failed.", this);
return;
}
if (eventType == NlsEvent::Close) {
LOG_INFO("Node(%p) will callback NlsEvent::Close frame.", this);
}
if (_handler == NULL) {
LOG_ERROR("Node(%p) event type:%d 's _handler is nullptr!", this, eventType)
} else {
if (NodeClosed == _workStatus) {
LOG_WARN("Node(%p) NlsEvent::Close has invoked, skip CloseCallback.",
this);
} else {
handlerFrame(useEvent);
if (eventType == NlsEvent::Close) {
_workStatus = NodeClosed;
LOG_INFO("Node(%p) callback NlsEvent::Close frame done.", this);
} else {
LOG_INFO("Node(%p) callback NlsEvent::%s frame done.", this,
useEvent->getMsgTypeString().c_str());
}
}
}
delete useEvent;
useEvent = NULL;
return;
}