Пример #1
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);
}
Пример #2
0
void JSONTest::testEmptyObjectElement()
{
	std::string json = "[{}]";
	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(Array::Ptr));

	Array::Ptr array = result.extract<Array::Ptr>();
	Object::Ptr object = array->getObject(0);
	assert(object->size() == 0);
}
Пример #3
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);
}
Пример #4
0
void JSONTest::testOptValue()
{
	std::string json = "{ }";
	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>();
	int n = object->optValue("test", 123);
	assert(n == 123);
}
Пример #5
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());
}
Пример #6
0
void ParseHandler::startArray()
{
	Array::Ptr newArr = new Array();

	if ( _stack.empty() ) // The first array
	{
		_result = newArr;
	}
	else
	{
		Var parent = _stack.top();

		if ( parent.type() == typeid(Array::Ptr) )
		{
			Array::Ptr arr = parent.extract<Array::Ptr>();
			arr->add(newArr);
		}
		else if ( parent.type() == typeid(Object::Ptr) )
		{
			poco_assert_dbg(!_key.empty());
			Object::Ptr obj = parent.extract<Object::Ptr>();
			obj->set(_key, newArr);
			_key.clear();
		}
	}

	_stack.push(newArr);
}
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;
}
Пример #8
0
void JSONTest::testTemplate()
{
	Template tpl;
	tpl.parse("Hello world! From <?= person.name ?>\n<?if person.toOld ?>You're too old<?endif?>\n");

	Object::Ptr data = new Object();
	Object::Ptr person = new Object();
	data->set("person", person);
	person->set("name", "Franky");
	person->set("toOld", true);
	tpl.render(data, std::cout);
}
Пример #9
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;
}
Пример #10
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;
	}
}
Пример #11
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()));
	}
}
Пример #12
0
	BOOST_FOREACH(const ConfigObject::Ptr& obj, objs) {
		Dictionary::Ptr result1 = new Dictionary();
		results->Add(result1);

		Dictionary::Ptr resultAttrs = new Dictionary();
		result1->Set("attrs", resultAttrs);

		BOOST_FOREACH(const String& joinAttr, joinAttrs) {
			Object::Ptr joinedObj;
			String prefix;

			if (joinAttr.IsEmpty()) {
				joinedObj = obj;
				prefix = type->GetName();
			} else {
				int fid = type->GetFieldId(joinAttr);
				joinedObj = obj->NavigateField(fid);

				if (!joinedObj)
					continue;

				Field field = type->GetFieldInfo(fid);
				prefix = field.NavigationName;
			}

			boost::algorithm::to_lower(prefix);

			Type::Ptr joinedType = joinedObj->GetReflectionType();

			for (int fid = 0; fid < joinedType->GetFieldCount(); fid++) {
				Field field = joinedType->GetFieldInfo(fid);
				String aname = prefix + "." + field.Name;
				if (!attrs.empty() && attrs.find(aname) == attrs.end())
					continue;

				Value val = joinedObj->GetField(fid);

				/* hide internal navigation fields */
				if (field.Attributes & FANavigation) {
					Value nval = joinedObj->NavigateField(fid);

					if (val == nval)
						continue;
				}

				Value sval = Serialize(val, FAConfig | FAState);
				resultAttrs->Set(aname, sval);
			}
		}
Пример #13
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);
	}
}
Пример #14
0
void ParseHandler::setValue(const Var& value)
{
	Var parent = _stack.top();

	if ( parent.type() == typeid(Array::Ptr) )
	{
		Array::Ptr arr = parent.extract<Array::Ptr>();
		arr->add(value);
	}
	else if ( parent.type() == typeid(Object::Ptr) )
	{
		poco_assert_dbg(!_key.empty());
		Object::Ptr obj = parent.extract<Object::Ptr>();
		obj->set(_key, value);
		_key.clear();
	}
}
Пример #15
0
//退出房间
void MeetingConnImpl::OnLeaveRoom(Object::Ptr object)
{
	Var varStatus = object->get("status");
	if(varStatus == 0)
	{

	}
}
Пример #16
0
bool FilterUtility::EvaluateFilter(ScriptFrame& frame, Expression *filter,
	const Object::Ptr& target, const String& variableName)
{
	if (!filter)
		return true;

	Type::Ptr type = target->GetReflectionType();
	String varName;

	if (variableName.IsEmpty())
		varName = type->GetName().ToLower();
	else
		varName = variableName;

	Namespace::Ptr frameNS;

	if (frame.Self.IsEmpty()) {
		frameNS = new Namespace();
		frame.Self = frameNS;
	} else {
		/* Enforce a namespace object for 'frame.self'. */
		ASSERT(frame.Self.IsObjectType<Namespace>());

		frameNS = frame.Self;
	}

	frameNS->Set("obj", target);
	frameNS->Set(varName, target);

	for (int fid = 0; fid < type->GetFieldCount(); fid++) {
		Field field = type->GetFieldInfo(fid);

		if ((field.Attributes & FANavigation) == 0)
			continue;

		Object::Ptr joinedObj = target->NavigateField(fid);

		if (field.NavigationName)
			frameNS->Set(field.NavigationName, joinedObj);
		else
			frameNS->Set(field.Name, joinedObj);
	}

	return Convert::ToBool(filter->Evaluate(frame));
}
Пример #17
0
Value icinga::GetPrototypeField(const Value& context, const String& field, bool not_found_error, const DebugInfo& debugInfo)
{
	Type::Ptr ctype = context.GetReflectionType();
	Type::Ptr type = ctype;

	do {
		Object::Ptr object = type->GetPrototype();

		if (object && object->HasOwnField(field))
			return object->GetFieldByName(field, false, debugInfo);

		type = type->GetBaseType();
	} while (type);

	if (not_found_error)
		BOOST_THROW_EXCEPTION(ScriptError("Invalid field access (for value of type '" + ctype->GetName() + "'): '" + field + "'", debugInfo));
	else
		return Empty;
}
vector<shared_ptr<FDSBucket> > GalaxyFDSClient::listBuckets() {
  string uri = formatUri(_pConfig->getBaseUri(), "", _emptySubResources);
  URI pocoUri(uri);

  shared_ptr<HTTPClientSession> pSession(_pSessionFacotry
      ->createClientSession(pocoUri));
  pSession->setHost(pocoUri.getHost());
  pSession->setPort(pocoUri.getPort());
  HTTPRequest request(HTTPRequest::HTTP_GET, uri, HTTPMessage::HTTP_1_1);
  prepareRequestHeaders(uri, HTTPRequest::HTTP_GET, "", _emptyStream,
      *_pEmptyMetadata, request);
  HTTPResponse response;

  ostream& os = pSession->sendRequest(request);
  istream& rs = pSession->receiveResponse(response);

  if (response.getStatus() != HTTPResponse::HTTP_OK) {
    stringstream msg;
    msg << "List buckets failed, status=" << response.getStatus() << ", reason=";
    StreamCopier::copyStream(rs, msg);
    throw GalaxyFDSClientException(response.getStatus(), msg.str());
  }

  vector<shared_ptr<FDSBucket> > res;
  Parser parser;
  parser.parse(rs);
  Var result = parser.result();
  Object::Ptr pObject = result.extract<Object::Ptr>();
  Object::Ptr pOwnerObject = pObject->getObject("owner");
  stringstream ss;
  pOwnerObject->stringify(ss);
  shared_ptr<Owner> pOwner = Owner::deserialize(ss);
  Array::Ptr pBucketsArray = pObject->getArray("buckets");
  for (size_t i = 0; i < pBucketsArray->size(); i++) {
    string bucketName = pBucketsArray->getObject(i)->getValue<string>("name");
    shared_ptr<FDSBucket> pBucket(new FDSBucket(bucketName));
    pBucket->setOwner(*pOwner);
    res.push_back(pBucket);
  }

  return res;
}
Пример #19
0
bool FilterUtility::EvaluateFilter(ScriptFrame& frame, Expression *filter,
    const Object::Ptr& target, const String& variableName)
{
	if (!filter)
		return true;

	Type::Ptr type = target->GetReflectionType();
	String varName;

	if (variableName.IsEmpty())
		varName = type->GetName().ToLower();
	else
		varName = variableName;

	Dictionary::Ptr vars;

	if (frame.Self.IsEmpty()) {
		vars = new Dictionary();
		frame.Self = vars;
	} else
		vars = frame.Self;

	vars->Set("obj", target);
	vars->Set(varName, target);

	for (int fid = 0; fid < type->GetFieldCount(); fid++) {
		Field field = type->GetFieldInfo(fid);

		if ((field.Attributes & FANavigation) == 0)
			continue;

		Object::Ptr joinedObj = target->NavigateField(fid);

		if (field.NavigationName)
			vars->Set(field.NavigationName, joinedObj);
		else
			vars->Set(field.Name, joinedObj);
	}

	return Convert::ToBool(filter->Evaluate(frame));
}
Пример #20
0
Poco::DynamicStruct Object::makeStruct(const Object::Ptr& obj)
{
	Poco::DynamicStruct ds;

	ConstIterator it  = obj->begin();
	ConstIterator end = obj->end();
	for (; it != end; ++it)
	{
		if (obj->isObject(it))
		{
			Object::Ptr pObj = obj->getObject(it->first);
			DynamicStruct str = makeStruct(pObj);
			ds.insert(it->first, str);
		}
		else if (obj->isArray(it))
		{
			Array::Ptr pArr = obj->getArray(it->first);
			std::vector<Poco::Dynamic::Var> v = Poco::JSON::Array::makeArray(pArr);
			ds.insert(it->first, v);
		}
		else
			ds.insert(it->first, it->second);
	}

	return ds;
}
Пример #21
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);
	}
	
}
Пример #22
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);
		}
	}
}
Пример #23
0
double ScriptUtils::Ptr(const Object::Ptr& object)
{
	return reinterpret_cast<intptr_t>(object.get());
}
Пример #24
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;
        }
    }
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;
    }
}
Пример #26
0
void MeetingConnImpl::OnLogout(Object::Ptr object)
{
	Var varStatus = object->get("status");
}
Пример #27
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);
	}
}
Пример #28
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);
	}
	
}
Пример #29
0
ObjectLock::ObjectLock(const Object::Ptr& object)
	: m_Object(object.get()), m_Locked(false)
{
	if (m_Object)
		Lock();
}
Пример #30
0
Dictionary::Ptr ObjectQueryHandler::SerializeObjectAttrs(const Object::Ptr& object,
	const String& attrPrefix, const Array::Ptr& attrs, bool isJoin, bool allAttrs)
{
	Type::Ptr type = object->GetReflectionType();

	std::vector<int> fids;

	if (isJoin && attrs) {
		ObjectLock olock(attrs);
		for (const String& attr : attrs) {
			if (attr == attrPrefix) {
				allAttrs = true;
				break;
			}
		}
	}

	if (!isJoin && (!attrs || attrs->GetLength() == 0))
		allAttrs = true;

	if (allAttrs) {
		for (int fid = 0; fid < type->GetFieldCount(); fid++) {
			fids.push_back(fid);
		}
	} else if (attrs) {
		ObjectLock olock(attrs);
		for (const String& attr : attrs) {
			String userAttr;

			if (isJoin) {
				String::SizeType dpos = attr.FindFirstOf(".");
				if (dpos == String::NPos)
					continue;

				String userJoinAttr = attr.SubStr(0, dpos);
				if (userJoinAttr != attrPrefix)
					continue;

				userAttr = attr.SubStr(dpos + 1);
			} else
				userAttr = attr;

			int fid = type->GetFieldId(userAttr);

			if (fid < 0)
				BOOST_THROW_EXCEPTION(ScriptError("Invalid field specified: " + userAttr));

			fids.push_back(fid);
		}
	}

	DictionaryData resultAttrs;
	resultAttrs.reserve(fids.size());

	for (int fid : fids) {
		Field field = type->GetFieldInfo(fid);

		Value val = object->GetField(fid);

		/* hide attributes which shouldn't be user-visible */
		if (field.Attributes & FANoUserView)
			continue;

		/* hide internal navigation fields */
		if (field.Attributes & FANavigation && !(field.Attributes & (FAConfig | FAState)))
			continue;

		Value sval = Serialize(val, FAConfig | FAState);
		resultAttrs.emplace_back(field.Name, sval);
	}

	return new Dictionary(std::move(resultAttrs));
}