Ejemplo n.º 1
0
void QueueApi::onBundleUpdated(const BundlePtr& aBundle, const PropertyIdSet& aUpdatedProperties, const string& aSubscription) {
    bundleView.onItemUpdated(aBundle, aUpdatedProperties);
    if (!subscriptionActive(aSubscription))
        return;

    addAsyncTask([=] {
        send(aSubscription, Serializer::serializeItem(aBundle, bundlePropertyHandler));
    });
}
Ejemplo n.º 2
0
void QueueApi::on(QueueManagerListener::BundleRemoved, const BundlePtr& aBundle) noexcept {
    bundleView.onItemRemoved(aBundle);
    if (!subscriptionActive("bundle_removed"))
        return;

    addAsyncTask([=] {
        send("bundle_removed", Serializer::serializeItem(aBundle, bundlePropertyHandler));
    });
}
Ejemplo n.º 3
0
	// Use async tasks because adding/removing HubInfos require calls to ClientListener (which is likely 
	// to cause deadlocks if done inside ClientManagerListener)
	void HubApi::on(ClientManagerListener::ClientCreated, const ClientPtr& aClient) noexcept {
		addAsyncTask([=] {
			addHub(aClient);
			if (!subscriptionActive("hub_created")) {
				return;
			}

			send("hub_created", serializeClient(aClient));
		});
	}
Ejemplo n.º 4
0
	void HubApi::on(ClientManagerListener::ClientRemoved, const ClientPtr& aClient) noexcept {
		addAsyncTask([=] {
			removeSubModule(aClient->getClientId());

			if (!subscriptionActive("hub_removed")) {
				return;
			}

			send("hub_removed", {
				{ "id", aClient->getClientId() }
			});
		});
	}
Ejemplo n.º 5
0
ZEND_METHOD( appnetServer , addAsynTask )
{
    long task_worker_id;
    size_t len;
    char* arg;

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl",  &arg , &len , &task_worker_id ) == FAILURE)
    {
        RETURN_FALSE;
    }

    addAsyncTask( arg , task_worker_id );
    RETURN_TRUE;
}
Ejemplo n.º 6
0
void QueueApi::on(DownloadManagerListener::BundleTick, const BundleList& tickBundles, uint64_t /*aTick*/) noexcept {
    bundleView.onItemsUpdated(tickBundles, { PROP_SPEED, PROP_SECONDS_LEFT, PROP_BYTES_DOWNLOADED, PROP_STATUS });
    if (!subscriptionActive("bundle_tick"))
        return;

    addAsyncTask([=] {
        json j;
        for (auto& b : tickBundles) {
            j.push_back(Serializer::serializeItem(b, bundlePropertyHandler));
        }

        send("bundle_tick", j);
    });
}