package com.tomhempel.unityudp.data

data class ReceivedMessage(
    val id: String,
    val data: String,
    val senderIp: String,
    val port: Int,
    val timestamp: Long = System.currentTimeMillis()
)

data class UdpPackageData(
    val id: String = "",
    val name: String = "",
    val data: String = "",
    val ipAddresses: List<String> = listOf("127.0.0.1"),
    val isBroadcast: Boolean = false
) {
    fun copyWith(
        id: String? = null,
        name: String? = null,
        data: String? = null,
        ipAddresses: List<String>? = null,
        isBroadcast: Boolean? = null
    ) = UdpPackageData(
        id = id ?: this.id,
        name = name ?: this.name,
        data = data ?: this.data,
        ipAddresses = ipAddresses ?: this.ipAddresses,
        isBroadcast = isBroadcast ?: this.isBroadcast
    )
}

data class ProjectData(
    val id: String = "",
    val name: String = "",
    val ipAddresses: List<String> = listOf("127.0.0.1"),
    val isBroadcast: Boolean = false,
    val port: Int = 8888,
    val packages: List<UdpPackageData> = emptyList()
) {
    fun copyWith(
        id: String? = null,
        name: String? = null,
        ipAddresses: List<String>? = null,
        isBroadcast: Boolean? = null,
        port: Int? = null,
        packages: List<UdpPackageData>? = null
    ) = ProjectData(
        id = id ?: this.id,
        name = name ?: this.name,
        ipAddresses = ipAddresses ?: this.ipAddresses,
        isBroadcast = isBroadcast ?: this.isBroadcast,
        port = port ?: this.port,
        packages = packages ?: this.packages
    )
}
