package com.insa.app.network;

import java.sql.Timestamp;
import java.util.Calendar;
import java.util.UUID;

public class NetworkMessage {
    private String content;
    private UUID emitter;
    private UUID recipient;
    private String timestamp;


    private NetworkMessage() {};

    public NetworkMessage(String content, UUID emitter, UUID recipient) {
        this.content = content;
        this.emitter = emitter;
        this.recipient = recipient;

        Calendar calendar = Calendar.getInstance();
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());

        calendar.setTimeInMillis(timestamp.getTime());
        int hour = calendar.get(Calendar.HOUR);
        int minute = calendar.get(Calendar.MINUTE);
        int second = calendar.get(Calendar.SECOND);
        this.timestamp = String.format("%dh%2d:%2d", hour, minute, second);

    }

    @Override
    public String toString() {
        return "NetworkMessage{" +
            ", content='" + content + '\'' +
            ", emitter=" + emitter +
            ", recipient=" + recipient +
            '}';
    }

    public String getContent() {
        return content;
    }

    public UUID getEmitterID() {
        return emitter;
    }

    public UUID getRecipientID() {
        return recipient;
    }

    public String getTimestamp() {
        return timestamp;
    }
}
