package com.qaup.collision.websocket.event;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.Instant;
import java.util.UUID;

import com.qaup.collision.websocket.message.CollisionWarningPayload;

/**
 * 碰撞预警事件
 * 当检测到碰撞风险时发布此事件
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class CollisionWarningEvent implements WebSocketEvent {
    
    private final String eventId;
    private final long timestamp;
    private final String eventType;
    private final CollisionWarningPayload payload;
    
    public CollisionWarningEvent(CollisionWarningPayload payload) {
        this.eventId = UUID.randomUUID().toString();
        this.timestamp = Instant.now().toEpochMilli() * 1000; // 微秒级时间戳
        this.eventType = "collision_warning";
        this.payload = payload;
    }
    
    @Override
    public String getEventId() {
        return eventId;
    }
    
    @Override
    public long getTimestamp() {
        return timestamp;
    }
    
    @Override
    public String getEventType() {
        return eventType;
    }
    
    @Override
    public CollisionWarningPayload getPayload() {
        return payload;
    }
} 