From d1d3df2a95d974aca168c46281389268602dc458 Mon Sep 17 00:00:00 2001 From: ThibaultBee <37510686+ThibaultBee@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:11:58 +0200 Subject: [PATCH] feat(lib): override equals and hashcode to compare with internal srt socket --- .../github/thibaultbee/srtdroid/models/Socket.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Socket.kt b/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Socket.kt index 24573f8a..d7ae28e8 100644 --- a/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Socket.kt +++ b/srtdroid/src/main/java/io/github/thibaultbee/srtdroid/models/Socket.kt @@ -1320,6 +1320,20 @@ private constructor(private val srtsocket: Int) : Closeable { */ fun available(): Int = getSockFlag(SockOpt.RCVDATA) as Int + /** + * Return [true] if internal SRT socket are equals + */ + override fun equals(other: Any?): Boolean { + if (other is Socket) { + return other.srtsocket == srtsocket + } + return false + } + + override fun hashCode(): Int { + return srtsocket.hashCode() + } + /** * This interface is used by a server [Socket] to notify SRT socket events. */