MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / runtime_worker_handle_subscribe

Function runtime_worker_handle_subscribe

src/daemon/runtime.c:1200–1226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1198}
1199
1200static bool runtime_worker_handle_subscribe(cbm_daemon_runtime_worker_t *worker,
1201 const uint8_t *payload, uint32_t length) {
1202 if (!runtime_worker_service_running(worker) || !payload ||
1203 length < SUBSCRIBE_REQUEST_PREFIX_SIZE) {
1204 return false;
1205 }
1206 uint32_t key_length = runtime_get_u32(payload);
1207 if (key_length == 0 || key_length > CBM_DAEMON_RUNTIME_PROJECT_KEY_MAX ||
1208 length != SUBSCRIBE_REQUEST_PREFIX_SIZE + key_length) {
1209 return false;
1210 }
1211 char project_key[CBM_DAEMON_RUNTIME_PROJECT_KEY_MAX + 1];
1212 memcpy(project_key, payload + SUBSCRIBE_REQUEST_PREFIX_SIZE, key_length);
1213 project_key[key_length] = '\0';
1214 if (memchr(project_key, '\0', key_length) != NULL) {
1215 return false;
1216 }
1217 cbm_daemon_subscription_id_t subscription_id = CBM_DAEMON_SUBSCRIPTION_ID_INVALID;
1218 cbm_daemon_subscription_result_t result = cbm_daemon_job_subscribe(
1219 worker->service->coordinator, worker->client_id, project_key, &subscription_id);
1220 uint8_t response[SUBSCRIBE_RESPONSE_SIZE];
1221 runtime_put_u32(response, (uint32_t)result);
1222 runtime_put_u64(response + 4, subscription_id);
1223 return runtime_worker_send_frame(worker, CBM_DAEMON_FRAME_RESPONSE,
1224 CBM_DAEMON_RUNTIME_OP_JOB_SUBSCRIBE, response,
1225 (uint32_t)sizeof(response));
1226}
1227
1228static bool runtime_worker_handle_unsubscribe(cbm_daemon_runtime_worker_t *worker,
1229 const uint8_t *payload, uint32_t length) {

Callers 1

Calls 6

runtime_get_u32Function · 0.85
cbm_daemon_job_subscribeFunction · 0.85
runtime_put_u32Function · 0.85
runtime_put_u64Function · 0.85

Tested by

no test coverage detected