bool ParseChatRoomEnterCallbackResultInfo(const std::string& result, ChatRoomInfo& room_info, ChatRoomMemberInfo& my_info)
{
	Json::Value values;
	Json::Reader reader;
	if (reader.parse(result, values) && values.isObject())
	{
		room_info.ParseFromJsonValue(values[kNIMChatRoomEnterCallbackKeyRoomInfo]);
		my_info.ParseFromJsonValue(values[kNIMChatRoomEnterCallbackKeyMyInfo]);
		return true;
	}
	return false;
}
Exemplo n.º 2
0
static void CallbackGetChatRoomInfo(__int64 room_id, int error_code, const char *result, const char *json_extension, const void *user_data)
{
	if (user_data)
	{
		ChatRoom::GetChatRoomInfoCallback *cb = (ChatRoom::GetChatRoomInfoCallback*)user_data;
		if (*cb)
		{
			Json::Value value;
			Json::Reader reader;
			if (reader.parse(PCharToString(result), value) && value.isObject())
			{
				ChatRoomInfo info;
				info.ParseFromJsonValue(value);
				(*cb)(room_id, error_code, info);
				return;
			}
			(*cb)(room_id, error_code, ChatRoomInfo());
		}
	}
}