Verified Commit efb2cad2 authored by AtjonTV's avatar AtjonTV

Net/Socket: Remove deprecated kSock API

parent 79c4b1be
Pipeline #2121 passed with stages
in 7 minutes and 30 seconds
......@@ -42,12 +42,12 @@ Table created from APIs removed/changed.
| 3.0.0 | Removal of `kLibRequire` (min,max) | Replaced with `kLibRequire` (min,max) using `types.SemVer` |
| 4.0.0 | Major renaming of packages | Following the suggestion from #1 |
| 4.1.0 | Renamed Queue.enqueue parameter `x` to `func` | Parameter names that make sense |
| 5.0.0 | Removed kSock (`klib.net.socket.kSock`) API | Was replaced with KSocket (`klib.net.socket.KSocket`) |
## Upcoming Breaking Changes
| Planed Since | Expecting Change in | Change | Reason |
|--------------|---------------------|--------|--------|
| 4.0.0 | 5.0.0 | Removal of kSock (`klib.net.socket.kSock`) API | Was replaced with KSocket (`klib.net.socket.KSocket`) |
| 4.1.0 | 5.0.0 | Removal of Directory (`klib.files.Directory`) API | Was replaced with Directory2 (`klib.files.Directory2`) |
| 5.0.0 | 5.1.0 | Copy Directory2 (`klib.files.Directory2`) to Directory (`klib.files.Directory`) | - |
| 5.1.0 | 6.0.0 | Removal of Directory2 (`klib.files.Directory2`) | Now named Directory (`klib.files.Directory`) |
......
kotlin.code.style=official
# kLib Version
klib_version=5.0.0-dev.1
klib_version=5.0.0-dev.2
# Versions
kotlin_version=1.3.61
......
#!/bin/bash
VERSION="5.0.0-dev.1"
VERSION="5.0.0-dev.2"
ATVG_DIST="file:///data/atjontv/git/maven-repo"
......
......@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.atvgstudios</groupId>
<artifactId>klib</artifactId>
<version>5.0.0-dev.1</version>
<version>5.0.0-dev.2</version>
<name>kLib</name>
<description>kLib is a Generic Kotlin Library to simplify development.</description>
<url>https://klib.atvg-studios.com/</url>
......
package klib.net.socket
import java.io.File
import java.io.InputStreamReader
import java.util.Timer
import java.util.TimerTask
import klib.extensions.reset
import klib.functions.currentMillis
/**
* Simple but useful one-way IPC socket
*
* @since 3.0.0
* @since 4.0.0 (Deprecated)
* @deprecated
* @author Thomas Obernosterer
*/
@Deprecated("kSock has been replaced by KSocket", ReplaceWith("KSocket", "klib.net.socket.KSocket"), DeprecationLevel.ERROR)
object kSock {
private var id = 0L
/**
* Open a timed one-way connection
*
* @param name File path of socket
* @param timed Refresh seconds
* @param block Refresh-Listener (Based on modify date)
*
* @since 3.0.0
* @author Thomas Obernosterer
*/
fun open(name: String = "/tmp/ksock-$id.sock", timed: Long = 100, block: (InputStreamReader) -> Unit) {
id++
// Store last modified date of file
var lastTime = currentMillis()
val file = File(name)
// Reset the file
file.reset()
// Create and start Timer
val timer = Timer()
timer.scheduleAtFixedRate(object : TimerTask() {
override fun run() {
val lastMod = file.lastModified()
if (lastMod != lastTime) {
lastTime = lastMod
block(file.reader())
file.reset()
}
}
}, timed, timed)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment