WebSocket으로 복합 이벤트를 실시간으로 수신하는 방법을 설명합니다.
/api/v1/ws/composite-events이 WebSocket 엔드포인트는 새로 생성되는 복합 이벤트를 실시간으로 스트리밍합니다.
연결이 성립되면 서버는 먼저 hello 텍스트 메시지를 한 번 보냅니다.
그 이후 도착하는 비어 있지 않은 JSON 메시지는 단일 복합 이벤트 조회 응답과 동일한 복합 이벤트 payload를 따릅니다.
WebSocket 연결을 생성할 때 Authorization 헤더에 Access Token을 포함해야 합니다.
헤더 형식은 Authorization: Bearer YOUR_ACCESS_TOKEN입니다.
이 WebSocket 엔드포인트는 별도의 쿼리 파라미터를 정의하지 않습니다.
hello를 보냅니다.초기 hello 이후 수신되는 메시지는 아래 구조를 따릅니다.
{
"id": "composite_evt_123",
"group_key": "edge-01:normal_speech_female",
"rule": {
"id": "rule_001",
"name": "Repeated Speech Cluster",
"description": "Groups repeated speech events within the same window",
"window_seconds": 30,
"min_events": 3,
"enabled": true,
"group_by": "label_id",
"include_label_ids": [
"normal_speech_female"
],
"include_mic_ids": [
"mic_001",
"mic_002"
]
},
"events": [
{
"id": "evt_001",
"confidence": 0.93,
"confidence_threshold": 0.5,
"sound_level": 71.2,
"sound_level_threshold": 65,
"description": "Repeated speech detected near entrance",
"audio_file": {
"file_path": "/audio/events/evt_001.wav"
},
"is_read": false,
"read_at": null,
"created_at": "2026-03-26T09:00:00Z",
"updated_at": "2026-03-26T09:00:05Z",
"label_id": "normal_speech_female",
"mic_id": "mic_001",
"label": {
"id": "normal_speech_female",
"name": {
"ko": "female speech",
"en": "normal speech female"
},
"active": true
},
"microphone": {
"id": "mic_001",
"name": "Entrance Mic",
"host": "172.16.10.21",
"subnet_mask": "255.255.255.0",
"mac_address": "00:11:22:33:44:55",
"microphone_type": "PDM_715IP",
"channel": {
"scheme": "rtsp",
"port": 554,
"path": "/stream",
"username": null,
"password": null
},
"console": {
"scheme": "http",
"port": 80,
"path": "/",
"username": "admin",
"password": "password"
},
"streaming": true,
"recording": true,
"edge_id": "edge_001",
"location": {
"latitude": 37.546344,
"longitude": 126.944322
},
"status": "active",
"thresholds": {},
"created_at": "2026-03-01T00:00:00Z",
"updated_at": "2026-03-26T09:00:05Z",
"deleted_at": null,
"reported_at": "2026-03-26T09:00:05Z",
"connected": true
}
}
],
"mics": [
{
"id": "mic_001",
"name": "Entrance Mic",
"host": "172.16.10.21",
"edge_id": "edge_001",
"status": "active",
"thresholds": {
"breathing_heavily": {
"sound_level_ge": 65,
"confidence_ge": 0.8
}
},
"location": {
"latitude": 37.546344,
"longitude": 126.944322
},
"created_at": "2026-03-01T00:00:00Z",
"updated_at": "2026-03-26T09:00:05Z"
}
],
"labels": [
{
"id": "normal_speech_female",
"name": {
"ko": "female speech",
"en": "normal speech female"
},
"active": true
}
],
"started_at": "2026-03-26T08:59:45Z"
}npx wscat -c "ws://{{EDGE_IP}}:8100/api/v1/ws/composite-events" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"