コード例 #1
0
// 处理已接收数据
bool RecvEnterConferenceTask::Handle(const TransportProtocol* tp) {
	bool result = false;
		
	AmfParser parser;
	amf_object_handle root = parser.Decode((char*)tp->data, tp->GetDataLength());
	if ( !root.isnull() && root->type == DT_OBJECT ) {

		// mFromId
		amf_object_handle fromIdObject = root->get_child("fromId");
		if ( !fromIdObject.isnull() && fromIdObject->type == DT_STRING ) {
			mFromId = fromIdObject->strValue;
		}

		// mToId
		amf_object_handle toIdObject = root->get_child("toId");
		if ( !toIdObject.isnull() && toIdObject->type == DT_STRING ) {
			mToId = toIdObject->strValue;
		}

		// mbAuth
		amf_object_handle authObject = root->get_child("auth");
		if ( !authObject.isnull() && authObject->type == DT_TRUE ) {
			mbAuth = true;
		}

		// mKey
		amf_object_handle keyObject = root->get_child("key");
		if ( !keyObject.isnull() && keyObject->type == DT_STRING ) {
			mKey = keyObject->strValue;
		}

		// m_errMsg
		amf_object_handle msgObject = root->get_child("msg");
		if ( !msgObject.isnull() && msgObject->type == DT_STRING ) {
			m_errMsg = msgObject->strValue;
		}

		if( mFromId.length() > 0 && mToId.length() > 0 && mKey.length() > 0 ) {
			result = true;
			m_errType = LCC_ERR_SUCCESS;
		}

	}

	// 协议解析失败
	if (!result) {
		m_errType = LCC_ERR_PROTOCOLFAIL;
		m_errMsg = "";
	}

//	Json::Value root;
//	Json::Reader reader;
//	if( reader.parse((char*)tp->data, root, false) ) {
//		if( root.isObject() ) {
//			if( root["userId1"].isString() && root["userId2"].isString() ) {
//				result = true;
//
//				m_userId1 = root["userId1"].asString();
//				m_userId2 = root["userId2"].asString();
//
//				m_errType = LCC_ERR_SUCCESS;
//			}
//		}
//	}

	// 打log
	FileLog("LiveChatClient", "RecvEnterConferenceTask::Handle() "
			"cmd:%d, "
			"errType:%d, "
			"errMsg:%s, "
			"mFromId:%s, "
			"mToId:%s, "
			"mbAuth:%s, "
			"mKey:%s",
			GetCmdCode(),
			m_errType,
			m_errMsg.c_str(),
			mFromId.c_str(),
			mToId.c_str(),
			mbAuth?"true":"false",
			mKey.c_str()
			);

	// 通知listener
	if ( NULL != m_listener ) {
		m_listener->OnRecvEnterConference(m_client, GetSeq(), mFromId, mToId, mKey, mbAuth, m_errType, m_errMsg);
	}
	
	return result;
}
コード例 #2
0
YK_BOOL YKOperInputItem::GetMainMaterialFlg()
{
	if(GetCmdCode().empty())
		return true;
	return GetItemReplaceSign();
}