예제 #1
0
void JSONTest::testObjectProperty()
{
	std::string json = "{ \"test\" : { \"property\" : \"value\" } }";
	Parser parser;
	Var result;

	try
	{
		DefaultHandler handler;
		parser.setHandler(&handler);
		parser.parse(json);
		result = handler.result();
	}
	catch(JSONException& jsone)
	{
		std::cout << jsone.message() << std::endl;
		assert(false);
	}

	assert(result.type() == typeid(Object::Ptr));

	Object::Ptr object = result.extract<Object::Ptr>();
	Var test = object->get("test");
	assert(test.type() == typeid(Object::Ptr));
	object = test.extract<Object::Ptr>();

	test = object->get("property");
	assert(test.isString());
	std::string value = test.convert<std::string>();
	assert(value.compare("value") == 0);
}
void LocationType::deserialize(Object::Ptr object){
    //std::string str = object->get("Latitude").convert<std::string>();
    //printf(str.c_str());
    
    if(object->has(LONGITUDE) && !object->isNull(LONGITUDE)){
        double d;
        Var longitude = object->get(LONGITUDE);
        Object::Ptr subObject = longitude.extract<Object::Ptr>();
        if (subObject->has("$")&& !subObject->isNull("$")) {
            d = subObject->get("$").convert<double>();
        }else{
            d = longitude.convert<double>();
        }
        this->longitude = d;
    }
    if(object->has(LATITUDE) && !object->isNull(LATITUDE)){
        double d;
        Var LatRaw = object->get(LATITUDE);
        Var longitude = object->get(LATITUDE);
        Object::Ptr subObject = longitude.extract<Object::Ptr>();
        if (subObject->has("$")&& !subObject->isNull("$")) {
            d = subObject->get("$").convert<double>();
        }else{
            d = longitude.convert<double>();
        }
        this->latitude = d;
    }
}
예제 #3
0
void MeetingConnImpl::OnGetChatHistory(Object::Ptr object)
{
	Var varStatus = object->get("status");
	if(varStatus == 0)
	{
		Var resultObj = object->get("result");
	}
	else
	{
		Var varMsg = object->get("msg");
		string errMsg = varMsg;
	}
}
예제 #4
0
void MeetingConnImpl::OnTextChat(Object::Ptr object)
{
	Var msg = object->get("msg");
	std::string strMsg = msg;
	Var varFamilly = object->get("fontName");
	std::string strFamilly = varFamilly;
	Var varFontSize = object->get("fontSize");
	uint32_t ulFontSize = varFontSize;
	Var varColor = object->get("color");
	uint32_t ulColor = varColor;
	Var varFlag = object->get("flag");
	uint64_t ulFlag = varFlag;
	Var varFromUserID = object->get("fromSessionID");
	uint64_t ulFromUserID = varFromUserID;
	Var varFromUserName = object->get("fromUserName");
	string strFromUserName = varFromUserName;
	Var varDate = object->get("date");
	time_t date = varDate;
	std::string msg2 = HTTPCookie::unescape(strMsg);
	std::string strFont2 = HTTPCookie::unescape(strFamilly);
	PMsgItem pMsgItem = new MsgItem();
	pMsgItem->ulUserID = ulFromUserID;
	pMsgItem->font_size = ulFontSize;
	pMsgItem->color = ulColor;
	pMsgItem->fontFlat = ulFlag;
	strcpy(pMsgItem->userName,strFromUserName.data());
	strcpy(pMsgItem->msg,msg2.data());
	strcpy(pMsgItem->familly,strFont2.data());
	//插入到列表
	m_chatMsgList.push_back(vector<PMsgItem>::value_type(pMsgItem));
	if(m_pIMeetingEvent)
	{
		m_pIMeetingEvent->On_MeetingEvent_Text_Msg(ulFromUserID,(char *)(msg2.data()),ulFontSize,ulFlag,ulColor,(char*)(strFont2.data()));
	}
}
예제 #5
0
//进入房间
void MeetingConnImpl::OnEnterRoom(Object::Ptr object)
{
	Var varStatus = object->get("status");
	uint32_t status = varStatus;
	if(status == 0)
	{
		Var varUserRole = object->get("userRole");
		m_userRole = varUserRole;
		GetRoomInfo(m_ulRoomID);
	}
	else
	{
		MeetingFrameImpl::GetInstance()->On_MeetingEvent_Enter_Room_Result(status,NULL);
	}
}
예제 #6
0
void JSONTest::testNullProperty()
{
	std::string json = "{ \"test\" : null }";
	Parser parser;

	Var result;
	try
	{
		DefaultHandler handler;
		parser.setHandler(&handler);
		parser.parse(json);
		result = handler.result();
	}
	catch(JSONException& jsone)
	{
		std::cout << jsone.message() << std::endl;
		assert(false);
	}
	assert(result.type() == typeid(Object::Ptr));

	Object::Ptr object = result.extract<Object::Ptr>();
	assert(object->isNull("test"));
	Var test = object->get("test");
	assert(test.isEmpty());
}
예제 #7
0
void JSONTest::testDouble3Property()
{
	std::string json = "{ \"test\" : 12e-34 }";
	Parser parser;
	Var result;

	try
	{
		DefaultHandler handler;
		parser.setHandler(&handler);
		parser.parse(json);
		result = handler.result();
	}
	catch(JSONException& jsone)
	{
		std::cout << jsone.message() << std::endl;
		assert(false);
	}

	assert(result.type() == typeid(Object::Ptr));

	Object::Ptr object = result.extract<Object::Ptr>();
	Var test = object->get("test");
	assert(test.isNumeric());
	double value = test;
	assert(value == 12e-34);
}
Var Query::find(const std::string& path) const
{
	Var result = _source;
	StringTokenizer tokenizer(path, ".");
	for(StringTokenizer::Iterator token = tokenizer.begin(); token != tokenizer.end(); token++)
	{
		if ( !result.isEmpty() )
		{
			std::vector<int> indexes;
			RegularExpression::MatchVec matches;
			int firstOffset = -1;
			int offset = 0;
			RegularExpression regex("\\[([0-9]+)\\]");
			while(regex.match(*token, offset, matches) > 0 )
			{
				if ( firstOffset == -1 )
				{
					firstOffset = static_cast<int>(matches[0].offset);
				}
				std::string num = token->substr(matches[1].offset, matches[1].length);
				indexes.push_back(NumberParser::parse(num));
				offset = static_cast<int>(matches[0].offset + matches[0].length);
			}

			std::string name(*token);
			if ( firstOffset != -1 )
			{
				name = name.substr(0, firstOffset);
			}

			if ( name.length() > 0 )
			{
				if ( result.type() == typeid(Object::Ptr) )
				{
					Object::Ptr o = result.extract<Object::Ptr>();
					result = o->get(name);
				}
			}

			if (    !result.isEmpty()
			        && !indexes.empty() )
			{
				for(std::vector<int>::iterator it = indexes.begin(); it != indexes.end(); ++it )
				{
					if ( result.type() == typeid(Array::Ptr) )
					{
						Array::Ptr array = result.extract<Array::Ptr>();
						result = array->get(*it);
						if ( result.isEmpty() )
						{
							break;
						}
					}
				}
			}
		}
	}
	return result;
}
예제 #9
0
//退出房间
void MeetingConnImpl::OnLeaveRoom(Object::Ptr object)
{
	Var varStatus = object->get("status");
	if(varStatus == 0)
	{

	}
}
예제 #10
0
void MeetingConnImpl::OnGetRoomUserList(Object::Ptr object)
{
	Var varStatus = object->get("status");
	if(varStatus == 0)
	{
		Var resultObj = object->get("result");
		Poco::JSON::Array::Ptr array =resultObj.extract<Poco::JSON::Array::Ptr>();
		for(Poco::Int32 i = 0; i<array->size();i++)
		{
			Parser parser;
			Var result;
			Var item = array->get(i);
			string strItem = item;
			try
			{

				result = parser.parse(strItem);

			}
			catch(JSONException& jsone)
			{
				std::cout << jsone.message() << std::endl;
				return;
			}

			Object::Ptr tempObj = result.extract<Object::Ptr>();
			Var varSessionID = tempObj->get("sessionID");
			Var varUserName = tempObj->get("userName");
			Var varUserRole = tempObj->get("userRole");
			Var varClientType = tempObj->get("clientType");
			
			string strUserName = varUserName;
			
			uint32_t userRole = varUserRole;
			uint32_t clientType = varClientType;
			uint64_t sessionID= varSessionID;

			MeetingFrameImpl::GetInstance()->On_MeetingEvent_Member_Online(sessionID,(char*)strUserName.data(),"",clientType,userRole);
		}
	}
}
예제 #11
0
bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringTokenizer& tokens)
{
    int part = -1;
    if (tokens.count() < 2)
    {
        sendTextFrame("error: cmd=load kind=syntax");
        return false;
    }

    std::string timestamp;
    parseDocOptions(tokens, part, timestamp);

    std::string renderOpts;
    if (!_docOptions.empty())
    {
        Parser parser;
        Poco::Dynamic::Var var = parser.parse(_docOptions);
        Object::Ptr object = var.extract<Object::Ptr>();
        renderOpts = object->get("rendering").toString();
    }

    assert(!_docURL.empty());
    assert(!_jailedFilePath.empty());

    std::unique_lock<std::recursive_mutex> lock(Mutex);

    _loKitDocument = _onLoad(getId(), _jailedFilePath, _docPassword, renderOpts, _haveDocPassword);
    if (!_loKitDocument)
    {
        Log::error("Failed to get LoKitDocument instance.");
        return false;
    }

    if (_multiView)
    {
        _viewId = _loKitDocument->getView();
        _loKitDocument->initializeForRendering((renderOpts.empty() ? nullptr : renderOpts.c_str()));
    }

    _docType = LOKitHelper::getDocumentTypeAsString(_loKitDocument->get());
    if (_docType != "text" && part != -1)
    {
        _loKitDocument->setPart(part);
    }

    // Respond by the document status, which has no arguments.
    Log::debug("Sending status after load.");
    if (!getStatus(nullptr, 0))
        return false;

    Log::info("Loaded session " + getId());
    return true;
}
예제 #12
0
//第一次握手
void MeetingConnImpl::OnHandSharke1(Object::Ptr object)
{
	Var varStatus = object->get("status");
	if(varStatus == 0)
	{
		Var varToken = object->get("token");
		string strToken = varToken;
		char msg2[1024];
		sprintf(msg2,"{\"cmd\":\"handSharke2\",\"token\":\"%s\"}\r\n",strToken.data());
		if(m_bRawSockConnected)
			m_pSock->sendBytes(msg2,strlen(msg2));
	}
	else
	{
		std::string strUpdateUrl = "http://onlycoder.net/meeting/setup.exe";
		if(object->has("updateUrl")){
			Var url = object->get("updateUrl");
			strUpdateUrl = url.toString();
		}
		if(m_pIMeetingEvent)
			m_pIMeetingEvent->On_MeetingEvent_UpdateSoft(strUpdateUrl);
	}
	
}
예제 #13
0
//得到房间列表
void MeetingConnImpl::OnGetRoomList(Object::Ptr object)
{
	FastMutex::ScopedLock autoLock(m_lock);
	Var varStatus = object->get("status");
	if(varStatus == 0)
	{
		try
		{
			Var resultObj = object->get("result");
			Poco::JSON::Array::Ptr array =resultObj.extract<Poco::JSON::Array::Ptr>();
			for(Poco::Int32 i = 0; i<array->size();i++)
			{
				Parser parser;
				Var result;
				Var item = array->get(i);
				string strItem = item;
				result = parser.parse(strItem);
				Object::Ptr tempObj = result.extract<Object::Ptr>();
				Var varRoomID = tempObj->get("roomID");
				Var varRoomName = tempObj->get("roomName");
				Var varRoomPassword = tempObj->get("roomPassword");
				Var varAdminPassword = tempObj->get("adminPassword");
				Var varMixAudio = tempObj->get("mixAudio");
				Var varAudioSamplerate = tempObj->get("audioSamplerate");
				Var varDefaultVideoSize = tempObj->get("defaultVideoSize");
				Var varIsPublic = tempObj->get("isPublic");
				Var varMaxUser = tempObj->get("maxUser");
				Var varOnlineUser = tempObj->get("onlineUser");
				Var varStartTime = tempObj->get("startTime");
				Var varEndTime = tempObj->get("endTime");
				Var varAudioType = tempObj->get("audioType");   //类型 会议,直播
				PROOM_INFO pRoomInfo = new ROOM_INFO();
				FastMutex::ScopedLock autoLock(m_lock);
				pRoomInfo->ulRoomID = varRoomID;
				strcpy(pRoomInfo->strRoomName,varRoomName.toString().data());
				strcpy(pRoomInfo->strPassword,varRoomPassword.toString().data());
				strcpy(pRoomInfo->strAdminPwd,varAdminPassword.toString().data());
				pRoomInfo->bMixAudio = varMixAudio;
				pRoomInfo->speakMode = varAudioType;
				pRoomInfo->sampleRate = varAudioSamplerate;
				pRoomInfo->defaultVideoSize = varDefaultVideoSize;
				pRoomInfo->maxUser = varMaxUser;
				pRoomInfo->startTime = varStartTime;
				pRoomInfo->endTime = varEndTime;
				if(varOnlineUser.isEmpty())
				{
					pRoomInfo->onlineUser = 0;
				}
				else
				{
					pRoomInfo->onlineUser = varOnlineUser;
				}
				//m_mapRoom.insert(UINT_VOID_MAP::ValueType(pRoomInfo->ulRoomID,pRoomInfo));
				m_pRoomList.push_back(vector<PROOM_INFO>::value_type(pRoomInfo));
			}
			if(array->size()>0)
				m_pIMeetingEvent->On_MeetingEvent_GetRoomList(array->size());
		}
		catch(Poco::Exception& exc)
		{
			std::cout <<"get room list error:"<< exc.message() << std::endl;
			return;
		}
	}
	else
	{
		Var varMsg = object->get("msg");
		string errMsg = varMsg;
		m_pIMeetingEvent->On_MeetingEvent_GetRoomList(0);
	}
}
예제 #14
0
void MeetingConnImpl::ProcessJsonCommand(char * buffer,Poco::Int32 nLen)
{
	Parser parser;
	Var result;
	//printf("\n %s len: %u\n",buffer,nLen);
	TCHAR strLog[1024];
	AA_UTF82W(strLog,buffer,1024);
	LogTrace(L"%s\n",strLog);
	try
	{
		result = parser.parse(buffer);
	}
	catch(JSONException& jsone)
	{
		//printf("%s \n",buffer);
		std::cout << jsone.message() << std::endl;
		return;
	}
	catch(Poco::Exception& exc)
	{
		//printf("json string parse error, len: %u",nLen);
		//printf("%s \n",buffer);
		std::cout << exc.message() << std::endl;
		m_pIMeetingEvent->OnNetEvent(NET_EVENT_JSON_ERROR,"json parse error");
		return;
	}
	Object::Ptr object = result.extract<Object::Ptr>();
	Var varCommand = object->get("cmd");
	std::string strCommand = varCommand;
	if(strCommand == "handSharke1_ret")
	{
		OnHandSharke1(object);
	}
	else if(strCommand == "handSharke2_ret")
	{
		OnHandSharke2(object);
	}
	else if(strCommand == "login_ret")
	{
		OnLogin(object);
	}
	else if(strCommand == "logout_ret")
	{
		OnLogout(object);
	}
	else if(strCommand == "enterRoom_ret")
	{
		OnEnterRoom(object);
	}
	else if(strCommand == "leaveRoom_ret")
	{
		OnLeaveRoom(object);
	}
	else if(strCommand == "getRoomUserList_ret")
	{
		OnGetRoomUserList(object);
	}
	else if(strCommand == "getRoomList_ret")
	{
		OnGetRoomList(object);
	}
	else if(strCommand == "getRoomInfo_ret")
	{
		OnGetRoomInfo(object);
	}
	else if(strCommand == "getChatHistory_ret")
	{
		OnGetChatHistory(object);
	}
	else if(strCommand == "textChat")
	{
		OnTextChat(object);
	}
	else if(strCommand == "transparentCmd")
	{
		OnTransparentCmd(object);
	}
	else if(strCommand == "loginWithRoomNo_ret")
	{
		OnLoginWithRoomNo(object);
	}

}
예제 #15
0
ObjectLock::ObjectLock(const Object::Ptr& object)
	: m_Object(object.get()), m_Locked(false)
{
	if (m_Object)
		Lock();
}
예제 #16
0
    void callback(const int nType, const std::string& rPayload)
    {
        auto lock = _session.getLock();

        // Cache important notifications to replay them when our client
        // goes inactive and loses them.
        if (nType == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR ||
            nType == LOK_CALLBACK_CURSOR_VISIBLE ||
            nType == LOK_CALLBACK_CELL_CURSOR ||
            nType == LOK_CALLBACK_CELL_FORMULA ||
            nType == LOK_CALLBACK_GRAPHIC_SELECTION ||
            nType == LOK_CALLBACK_TEXT_SELECTION ||
            nType == LOK_CALLBACK_TEXT_SELECTION_START ||
            nType == LOK_CALLBACK_TEXT_SELECTION_END ||
            nType == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED)
        {
            _session.setDocState(nType, rPayload);
        }

        const auto typeName = LOKitHelper::kitCallbackTypeToString(nType);
        if (_session.isCloseFrame())
        {
            Log::trace("Skipping callback [" + typeName + "] on closing session " + _session.getName());
            return;
        }
        else if (_session.isDisconnected())
        {
            Log::trace("Skipping callback [" + typeName + "] on disconnected session " + _session.getName());
            return;
        }
        else if (!_session.isActive())
        {
            // Pass save notifications through.
            if (nType != LOK_CALLBACK_UNO_COMMAND_RESULT || rPayload.find(".uno:Save") == std::string::npos)
            {
                Log::trace("Skipping callback [" + typeName + "] on inactive session " + _session.getName());
                return;
            }
        }

        Log::trace() << "CallbackWorker::callback [" << _session.getName() << "]: "
                     << typeName << " [" << rPayload << "]." << Log::end;
        switch (nType)
        {
        case LOK_CALLBACK_INVALIDATE_TILES:
            {
                const auto lokitDoc = _session.getLoKitDocument();
                assert(lokitDoc);
                assert(lokitDoc->pClass);
                assert(lokitDoc->pClass->getPart);

                // Text docs have a single coordinate system.
                const auto curPart = (_session.getDocType() == "text")
                                   ? 0
                                   : lokitDoc->pClass->getPart(lokitDoc);

                StringTokenizer tokens(rPayload, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
                if (tokens.count() == 4)
                {
                    int x, y, width, height;
                    try
                    {
                        x = std::stoi(tokens[0]);
                        y = std::stoi(tokens[1]);
                        width = std::stoi(tokens[2]);
                        height = std::stoi(tokens[3]);
                    }
                    catch (const std::out_of_range&)
                    {
                        // something went wrong, invalidate everything
                        Log::warn("Ignoring integer values out of range: " + rPayload);
                        x = 0;
                        y = 0;
                        width = INT_MAX;
                        height = INT_MAX;
                    }

                    _session.sendTextFrame("invalidatetiles:"
                                           " part=" + std::to_string(curPart) +
                                           " x=" + std::to_string(x) +
                                           " y=" + std::to_string(y) +
                                           " width=" + std::to_string(width) +
                                           " height=" + std::to_string(height));
                }
                else
                {
                    _session.sendTextFrame("invalidatetiles: " + rPayload);
                }
            }
            break;
        case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
            _session.sendTextFrame("invalidatecursor: " + rPayload);
            break;
        case LOK_CALLBACK_TEXT_SELECTION:
            _session.sendTextFrame("textselection: " + rPayload);
            break;
        case LOK_CALLBACK_TEXT_SELECTION_START:
            _session.sendTextFrame("textselectionstart: " + rPayload);
            break;
        case LOK_CALLBACK_TEXT_SELECTION_END:
            _session.sendTextFrame("textselectionend: " + rPayload);
            break;
        case LOK_CALLBACK_CURSOR_VISIBLE:
            _session.sendTextFrame("cursorvisible: " + rPayload);
            break;
        case LOK_CALLBACK_GRAPHIC_SELECTION:
            _session.sendTextFrame("graphicselection: " + rPayload);
            break;
        case LOK_CALLBACK_CELL_CURSOR:
            _session.sendTextFrame("cellcursor: " + rPayload);
            break;
        case LOK_CALLBACK_CELL_FORMULA:
            _session.sendTextFrame("cellformula: " + rPayload);
            break;
        case LOK_CALLBACK_MOUSE_POINTER:
            _session.sendTextFrame("mousepointer: " + rPayload);
            break;
        case LOK_CALLBACK_HYPERLINK_CLICKED:
            _session.sendTextFrame("hyperlinkclicked: " + rPayload);
            break;
        case LOK_CALLBACK_STATE_CHANGED:
            _session.sendTextFrame("statechanged: " + rPayload);
            break;
        case LOK_CALLBACK_SEARCH_NOT_FOUND:
            _session.sendTextFrame("searchnotfound: " + rPayload);
            break;
        case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
            _session.sendTextFrame("searchresultselection: " + rPayload);
            break;
        case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
            _session.getStatus("", 0);
            _session.getPartPageRectangles("", 0);
            break;
        case LOK_CALLBACK_SET_PART:
            _session.sendTextFrame("setpart: " + rPayload);
            break;
        case LOK_CALLBACK_UNO_COMMAND_RESULT:
            _session.sendTextFrame("unocommandresult: " + rPayload);
            break;
        case LOK_CALLBACK_ERROR:
            {
                Parser parser;
                Poco::Dynamic::Var var = parser.parse(rPayload);
                Object::Ptr object = var.extract<Object::Ptr>();

                _session.sendTextFrame("error: cmd=" + object->get("cmd").toString() +
                        " kind=" + object->get("kind").toString() + " code=" + object->get("code").toString());
            }
            break;
        case LOK_CALLBACK_CONTEXT_MENU:
            _session.sendTextFrame("contextmenu: " + rPayload);
            break;
        case LOK_CALLBACK_STATUS_INDICATOR_START:
            _session.sendTextFrame("statusindicatorstart:");
            break;
        case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE:
            _session.sendTextFrame("statusindicatorsetvalue: " + rPayload);
            break;
        case LOK_CALLBACK_STATUS_INDICATOR_FINISH:
            _session.sendTextFrame("statusindicatorfinish:");
            break;
        }
    }
예제 #17
0
void MeetingConnImpl::OnTransparentCmd(Object::Ptr object)
{
	Var varFromUserID = object->get("fromSessionID");
	uint64_t fromSessionID = varFromUserID;
	Var varToUserID = object->get("toSessionID");
	uint64_t toSessionID = varToUserID;
	Var varFromUserName = object->get("fromUserName");
	std::string strFromUserName = varFromUserName;
	Var varSubCommand = object->get("subCmd");
	std::string strSubCommand = varSubCommand;
	//解析内置命令,UserOnline,UserOffline,OnModifyUserFeeling
	Parser parser;
	Var result;
	//try
	{
		result = parser.parse(strSubCommand);
	}
	/*catch(JSONException& jsone)
	{
	std::cout << jsone.message() << std::endl;
	}*/
	Object::Ptr subObj = result.extract<Object::Ptr>();
	Var varCommand = subObj->get("cmd");
	std::string strCommand = varCommand;
	printf("%s \n",strCommand.data());
	if(strCommand == "userOnline")
	{
		Var varSessionID = subObj->get("sessionID");
		Var varUserName = subObj->get("userName");
		Var varClientType = subObj->get("clientType");
		Var varUserRole = subObj->get("userRole");
		
		string strUserName = varUserName;
		
		uint32_t userRole = varUserRole;
		uint32_t clientType = varClientType;
		uint64_t sessionID = varSessionID;
		MeetingFrameImpl::GetInstance()->On_MeetingEvent_Member_Online(sessionID,(char*)strUserName.data(),"",clientType,userRole);
	}
	else if(strCommand == "userOffline")
	{
		Var varSessionID = subObj->get("sessionID");
		uint64_t sessionID = varSessionID;
		MeetingFrameImpl::GetInstance()->On_MeetingEvent_Member_Offline(sessionID);
	}
	else if(strCommand == "recvMyVideo")
	{
		
		Var varSSRC = subObj->get("ssrc");
		Var varFromSessionID = subObj->get("fromSessionID");
		uint32_t ulSSRC = varSSRC;
		uint64_t ulFromSessionID = varFromSessionID;
		Var varChannelID = subObj->get("channelID");
		uint32_t ulChannelID = varChannelID;
		MeetingFrameImpl::GetInstance()->OnRecvRemoteVideo(ulFromSessionID,ulChannelID,ulSSRC);
	}
	else if(strCommand == "requireKeyFrame")
	{
		Var varSSRC = subObj->get("ssrc");
		uint32_t ulSSRC = varSSRC;
		MeetingFrameImpl::GetInstance()->On_MeetingEvent_RequireKeyFrame(ulSSRC);
	}
	else if(strCommand == "closeMyVideo")
	{
		Var varFromSessionID = subObj->get("fromSessionID");
		Var varChannelID = subObj->get("channelID");
		uint64_t ulFromSessionID = varFromSessionID;
		uint32_t ulChannelID = varChannelID;
		MeetingFrameImpl::GetInstance()->OnCloseRemoteVideo(ulFromSessionID,ulChannelID);
	}
	else if(strCommand == "recvMyAudio")
	{
		Var varSSRC = subObj->get("ssrc");
		Var varFromSessionID = subObj->get("fromSessionID");
		uint32_t ulSSRC = varSSRC;
		uint64_t ulFromSessionID = varFromSessionID;
		Var varChannelID = subObj->get("channelID");
		uint32_t ulChannelID = varChannelID;
		MeetingFrameImpl::GetInstance()->OnRecvRemoteAudio(ulFromSessionID,ulChannelID,ulSSRC);
	}
	else if(strCommand == "closeMyAudio")
	{
		Var varFromSessionID = subObj->get("fromSessionID");
		Var varChannelID = subObj->get("channelID");
		uint64_t ulFromSessionID = varFromSessionID;
		uint32_t ulChannelID = varChannelID;
		MeetingFrameImpl::GetInstance()->OnCloseRemoteAudio(ulFromSessionID,ulChannelID);
	}
	else if(strCommand == "setSpeaker")
	{
		Var varBSet = subObj->get("bSet");
		uint32_t ulSet = varBSet;
		Var varFromUserID = subObj->get("sessionID");
		uint64_t ulFromUserID = varFromUserID;
		if(ulFromUserID==m_mySessionID)
			MeetingFrameImpl::GetInstance()->OnSetAsSpeaker(ulFromUserID,ulSet);
	}
	else if(strCommand == "setSpeakMode")
	{
		Var varMode = subObj->get("mode");
		int mode = varMode;
		MeetingFrameImpl::GetInstance()->On_MeetingEvent_SpeakMode_Change(mode);
	}
	else if(strCommand == "setRoomMode")
	{
		Var varMode = subObj->get("mode");
		int mode = varMode;
		MeetingFrameImpl::GetInstance()->On_MeetingEvent_RoomMode_Change(mode);
	}
	else if(strCommand == "setShower")
	{
		Var varBSet = subObj->get("bSet");
		uint32_t ulSet = varBSet;
		Var varFromUserID = subObj->get("sessionID");
		uint64_t ulFromUserID = varFromUserID;
		MeetingFrameImpl::GetInstance()->OnSetAsShower(ulFromUserID,ulSet);
	}
	else if(strCommand == "setAdmin")
	{
		Var varBSet = subObj->get("bSet");
		uint32_t ulSet = varBSet;
		Var varFromUserID = subObj->get("sessionID");
		uint64_t ulFromUserID = varFromUserID;
		MeetingFrameImpl::GetInstance()->OnSetAsAdmin(ulFromUserID,ulSet);
	}
	else if(strCommand == "setBigVideo")
	{
		Var varFromUserID = subObj->get("sessionID");
		uint64_t ulFromUserID = varFromUserID;
		MeetingFrameImpl::GetInstance()->OnSetAsBigVideo(ulFromUserID);
	}
	else if(strCommand == "applySpeaker")
	{
		Var varFromUserID = subObj->get("fromSessionID");
		uint64_t ulFromUserID = varFromUserID;

		MeetingFrameImpl::GetInstance()->OnApplySpeaker(ulFromUserID);
	}
	else if(strCommand == "cancelApplySpeaker")
	{
		Var varFromUserID = subObj->get("fromSessionID");
		uint64_t ulFromUserID = varFromUserID;
		MeetingFrameImpl::GetInstance()->OnCancelApplySpeaker(ulFromUserID);
	}
	else if(strCommand == "openDoc")
	{
		Var varUrl = subObj->get("url");
		std::string url = varUrl;
		Var varIndex = subObj->get("index");
		Var varTotal = subObj->get("total");
		int index = varIndex;
		int total = varTotal;
		if(m_pIMeetingEvent)
		{
			m_pIMeetingEvent->On_MeetingEvent_OpenDoc(url,index,total);
		}
	}
	else if(strCommand == "closeDoc")
	{
		if(m_pIMeetingEvent)
		{
			m_pIMeetingEvent->On_MeetingEvent_CloseDoc();
		}
	}
	else if(strCommand == "stopShareCursor")
	{
		if(m_pIMeetingEvent)
		{
			m_pIMeetingEvent->On_MeetingEvent_StopShareCursor();
		}
	}
	else if(strCommand == "shareCursor")
	{
		Var varX = subObj->get("x");
		Var varY = subObj->get("y");
		float x = varX;
		float y = varY;
		if(m_pIMeetingEvent)
		{
			m_pIMeetingEvent->On_MeetingEvent_ShareCursor(x,y);
		}
	}else if(strCommand == "startVideoMonitor"){

		MeetingFrameImpl::GetInstance()->OnStartVideoMonitor();

	}else if(strCommand == "stopVideoMonitor"){
		MeetingFrameImpl::GetInstance()->OnStopVideoMonitor();

	}else if(strCommand == "pauseVideo"){
		MeetingFrameImpl::GetInstance()->OnPauseVideo();

	}else if(strCommand == "resumeVideo"){
		MeetingFrameImpl::GetInstance()->OnResumeVideo();

	}else if(strCommand == "sendVideoSSRCToAdmin"){
		Var varSSRC = subObj->get("ssrc");
		uint32_t ssrc = varSSRC;
		MeetingFrameImpl::GetInstance()->OnRecvVideoSSRC(fromSessionID,ssrc);
	}
	
}
예제 #18
0
void MeetingConnImpl::OnGetRoomInfo(Object::Ptr object)
{
	FastMutex::ScopedLock autoLock(m_lock);
	Var varStatus = object->get("status");
	int docIndex = 0;
	int docTotal = 0;
	int shareDoc = 0;
	std::string docName = "";
	if(object->isNull("shareDoc")==false)
	{
		shareDoc = object->get("shareDoc");
		if(shareDoc == 1)
		{
			docIndex = object->get("docIndex");
			docTotal = object->get("docTotal");
			docName =  object->get("docName").toString();
		}
	}

	if(varStatus == 0)
	{
		Var resultObj;
		try
		{
			resultObj = object->get("result");
		}
		catch(JSONException& jsone)
		{
			std::cout << jsone.message() << std::endl;
			return;
		}
		Object::Ptr subObj = resultObj.extract<Object::Ptr>();
		Var varRoomName = subObj->get("roomName");
		Var varRoomID = subObj->get("roomID");
		Var varAdminPassword= subObj->get("adminPassword");
		Var varRoomPassword = subObj->get("roomPassword");
		Var varAudioType = subObj->get("audioType");
		Var varIsPublic = subObj->get("isPublic");
		Var varMixAudio = subObj->get("mixAudio");
		Var varDefaultVideoSize = subObj->get("defaultVideoSize");
		Var varAudioSamplate = subObj->get("audioSamplerate");
		Var varStartTime = subObj->get("startTime");
		Var varEndTime = subObj->get("endTime");
		Var varOnlineUser = subObj->get("onlineUser");
		string strRoomName = varRoomName;
		uint32_t roomID = varRoomID;
		string strPassword = varRoomPassword;
		string strAdminPassword = varAdminPassword;
		uint32_t defaultVideoSize = varDefaultVideoSize;
		uint32_t audioType = varAudioType;
		uint32_t isPublic = varIsPublic;
		uint32_t mixAudio = varMixAudio;
		uint32_t audioSamplate = 0;
		time_t startTime = varStartTime;
		time_t endTime = varEndTime;
		
		ROOM_INFO rs;
		rs.bMixAudio =mixAudio;
		rs.sampleRate = audioSamplate;
		rs.speakMode = audioType;
		rs.defaultVideoSize = defaultVideoSize;
		rs.ulRoomID = roomID;
		rs.ulIsPublic = isPublic;
		rs.roomMode = 1;
		rs.sampleRate = varAudioSamplate;
		rs.startTime = startTime;
		rs.endTime = endTime;
		if(varOnlineUser.isEmpty())
		{
			rs.onlineUser = 0;
		}
		else
		{
			rs.onlineUser = varOnlineUser;
		}
		if(subObj->has("roomType"))
		{
			Var varRoomType = subObj->get("roomType");
			unsigned int ulRoomType = varRoomType;
			rs.roomMode = ulRoomType;
		}

		if(subObj->has("bigVideoUser"))
		{
			Var varbigVideoUser = subObj->get("bigVideoUser");
			uint64_t ulBigVideoUser = varbigVideoUser;
			rs.bigVideoUser = ulBigVideoUser;
		}
		strcpy(rs.strAdminPwd,strAdminPassword.data());
		strcpy(rs.strRoomName,strRoomName.data());
		MeetingFrameImpl::GetInstance()->On_MeetingEvent_Enter_Room_Result(0,(char*)&rs);
		if(shareDoc==1)
		{
			if(m_pIMeetingEvent)
			{
				m_pIMeetingEvent->On_MeetingEvent_OpenDoc(docName,docIndex,docTotal);
			}
		}
		GetRoomUserList(m_ulRoomID);
	}
	else
	{
		Var varMsg = object->get("msg");
		string errMsg = varMsg;
		MeetingFrameImpl::GetInstance()->On_MeetingEvent_Enter_Room_Result(1,NULL);
	}
}
예제 #19
0
void MeetingConnImpl::OnLogout(Object::Ptr object)
{
	Var varStatus = object->get("status");
}
예제 #20
0
void MeetingConnImpl::OnLogin(Object::Ptr object)
{
	Var varStatus = object->get("status");
	uint32_t statusCode = varStatus;
	switch(statusCode)
	{
	case 0:
		{
			m_bHasLogined = true;
			Var varUserName = object->get("userName");
			
			string userName = varUserName;
			
			strcpy(m_strUserName,userName.data());
			//解析配置项
			Var varConfig = object->get("config");
			if(!varConfig.isEmpty())
			{
				std::string strConfig = varConfig;
				//解析内置命令,UserOnline,UserOffline,OnModifyUserFeeling
				Parser parser;
				Var result;
				try
				{
					result = parser.parse(strConfig);
				}
				catch(JSONException& jsone)
				{
					std::cout << jsone.message() << std::endl;
				}
				Object::Ptr subObj = result.extract<Object::Ptr>();
				Var varMediaHost = subObj->get("MediaHost");
				Var varRtpMediaPort = subObj->get("RtpMediaPort");
				Var varMixAudioPort = subObj->get("MixAudioPort");
				Var varBaseUrl = subObj->get("BaseUrl");
				if(!varMediaHost.isEmpty())
				{
					std::string strServer = varMediaHost;
					strcpy(MeetingFrameImpl::GetInstance()->m_strMediaHost,strServer.data());
				}

				if(!varBaseUrl.isEmpty())
				{
					std::string strBaseUrl = varBaseUrl;
					strcpy(MeetingFrameImpl::GetInstance()->m_strBaseUrl,strBaseUrl.data());
				}

				if(!varRtpMediaPort.isEmpty())
				{
					MeetingFrameImpl::GetInstance()->m_RtpMediaPort = (int)varRtpMediaPort;
				}
				if(!varMixAudioPort.isEmpty())
				{
					MeetingFrameImpl::GetInstance()->m_MixAudioPort = (int)varMixAudioPort;
				}
			}
			else
			{
				//没有取到配置项目
			}
			

			if(m_pIMeetingEvent)
			{
				MeetingFrameImpl::GetInstance()->On_MeetingEvent_Login_Result(0,"login success");
			}
			break;
		}
	default:
		{
			Var varMsg = object->get("msg");
			string strMsg = varMsg;
			if(m_pIMeetingEvent)
			{
				MeetingFrameImpl::GetInstance()->On_MeetingEvent_Login_Result(statusCode,(char*)strMsg.data());
			}
		}
	}
	
}
예제 #21
0
//第二次握手
void MeetingConnImpl::OnHandSharke2(Object::Ptr object)
{
	Var varSessionID = object->get("sessionID");
	m_mySessionID = varSessionID;
	m_bLogicServerConnected = true;
}
예제 #22
0
double ScriptUtils::Ptr(const Object::Ptr& object)
{
	return reinterpret_cast<intptr_t>(object.get());
}
예제 #23
0
	void doSearch( Utility::MTInput & input,
			Utility::MTOutput & mtOutput,
			Utility::MTOutput & mtConsoleOutput,
			size_t startLine ) const
	{
		Poco::Net::HTTPClientSession session( m_uri.getHost(), m_uri.getPort() );
		{
			Utility::MTOutput::unique_lock lock( mtConsoleOutput.acquire());
			mtConsoleOutput.os() << "Thread " << pthread_self() << " starting ";
			mtConsoleOutput.flush();
		}

		std::string line;

		while( size_t lineNum = input.getline( line ))
		{
			if( lineNum < startLine )
				continue;

			std::string path;
			bool success = false;
			size_t maxTries = 4;
			while( !success && maxTries )
			{
				try
				{
					Utility::StrTuple term = Utility::delimitedText( line, '\t' );
					if( term.size() < 4 )
						break;

					std::string artist = term[2];
					std::string title = Utility::trim(term[3]);
					path = make_request( artist + ' ' + title );
					Poco::Net::HTTPRequest request( Poco::Net::HTTPRequest::HTTP_GET, path, Poco::Net::HTTPMessage::HTTP_1_1 );
					Poco::Net::HTTPResponse response;
					session.sendRequest(request);
					std::istream& rs = session.receiveResponse(response);

					using Poco::Dynamic::Var;
					using namespace Poco::JSON;
					Parser parser;
					Var result = parser.parse(rs);
					Object::Ptr obj = result.extract<Object::Ptr>();
					int nResults = obj->getValue<int>("resultCount");

					{
						Utility::MTOutput::unique_lock lock( mtConsoleOutput.acquire());
						mtConsoleOutput.os() << lineNum << ": " << path << ' ' << nResults
								<< " results " << std::endl;
					}

					if( nResults )
					{
						Array::Ptr arr;
						arr = obj->getArray( "results" );
						if( !arr )
						{
							std::cerr << "Could not get results " << std::endl;
							continue;
						}
						std::string releaseDate;
						std::string genre;
						std::string artistName; // on iTunes
						std::string trackName; // on iTunes
						bool found = false;
						// if there is more than one see if there is an exact match. Otherwise use the first result
						for( size_t i = 0; !found && i < nResults ; ++i )
						{
							Object::Ptr result = arr->getObject(i);
							if( !result )
							{
								std::cerr << " Could not get result " << i << std::endl;
								continue;
							}
							// get ArtistName and Title and see if they match ours
							Var item = result->get( "artistName" );
							if( item.isString() )
								artistName = item.convert< std::string >();

							item = result->get( "trackName" );

							if( item.isString() )
								trackName = item.convert< std::string >();

							if( (artistName == artist && trackName == title) ) // we have an exact match so continue
								found = true;

							// if no exact matches are found we use the first one.
							// We could use a better way to match the search eg case insensitive, removing featured acts etc.
							if( found || i == 0 )
							{
								item = result->get( "releaseDate");
								if( item.isString() )
								{
									std::string releaseDateStr = item.convert< std::string >();
									releaseDate = releaseDateStr.substr( 0, releaseDateStr.find('T') );
								}
								item = result->get( "primaryGenreName" );
								if( item.isString() )
									genre = item.convert< std::string >();
							}
						}

						if( m_filteredGenres.count( genre ) == 0 )
						{
							Utility::MTOutput::unique_lock lock( mtOutput.acquire());
						// output the result. Spotify link, artist(spotify), title(spotify)
						// artist(iTunes), title(iTunes), releaseDate, genre, numTracks (term[4])
							mtOutput.os() << lineNum << '\t' <<
									term[0] << '\t' << term[1] << '\t' << artist << '\t' << title << '\t' <<
									artistName << '\t' << trackName << '\t' << releaseDate << '\t' << genre << '\t' <<  term[4] << '\n';

							mtOutput.flush();
						}
					}
					success = true;
				}
				catch( std::exception const& err )
				{
					success = false;
					if( --maxTries )
					{
						sleep(1);
					}
					else
					{
						Utility::MTOutput::unique_lock lock( mtConsoleOutput.acquire());
						std::cerr << "ERROR: " << err.what() << lineNum << ": " << path  << std::endl;
					}
				}
			}
		}
		{
			Utility::MTOutput::unique_lock lock( mtConsoleOutput.acquire());
			mtConsoleOutput.os() << "Thread " << pthread_self() << " exiting\n";
			mtConsoleOutput.flush();
		}
	}