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

Function runtime_worker_handle_subscribe

src/daemon/runtime.c:1192–1218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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