Created
February 11, 2026 19:58
-
-
Save LethalMaus/1920acde7fe40501054c9d25e73348fe to your computer and use it in GitHub Desktop.
ZeroMq.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import kotlinx.coroutines.CoroutineScope | |
| import kotlinx.coroutines.Dispatchers | |
| import kotlinx.coroutines.Job | |
| import kotlinx.coroutines.launch | |
| import org.zeromq.SocketType | |
| import org.zeromq.ZContext | |
| import org.zeromq.ZMQ | |
| import org.zeromq.ZMQException | |
| import java.io.Closeable | |
| class ZeroMqClient( | |
| private val subPort: Int? = null, // eg. 54054, | |
| private val pubPort: Int? = null, // eg. 54055, | |
| private val messageCallback: ((String) -> Unit)? = null, | |
| private val onConnectionChanged: ((Boolean) -> Unit)? = null | |
| ) : Closeable { | |
| private var context: ZContext? = null | |
| private var subSocket: ZMQ.Socket? = null | |
| private var pubSocket: ZMQ.Socket? = null | |
| private var isRunning = false | |
| private var receiveJob: Job? = null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment