VPN Hotspot 2.0: Client+ (#39)
Fix #13, #38. I don't have a lot of confidence that this would work very well for every device. Also here's an SQL command that hopefully somebody could make into the app for me: `SELECT TrafficRecord.mac, SUM(TrafficRecord.sentPackets), SUM(TrafficRecord.sentBytes), SUM(TrafficRecord.receivedPackets), SUM(TrafficRecord.receivedBytes) FROM TrafficRecord LEFT JOIN TrafficRecord AS Next ON TrafficRecord.id = Next.previousId WHERE Next.id IS NULL GROUP BY TrafficRecord.mac;`
This commit is contained in:
@@ -12,11 +12,8 @@ open class Event0 : ConcurrentHashMap<Any, () -> Unit>() {
|
||||
}
|
||||
|
||||
class StickyEvent0 : Event0() {
|
||||
override fun put(key: Any, value: () -> Unit): (() -> Unit)? {
|
||||
val result = super.put(key, value)
|
||||
if (result == null) value()
|
||||
return result
|
||||
}
|
||||
override fun put(key: Any, value: () -> Unit): (() -> Unit)? =
|
||||
super.put(key, value).also { if (it == null) value() }
|
||||
}
|
||||
|
||||
open class Event1<T> : ConcurrentHashMap<Any, (T) -> Unit>() {
|
||||
@@ -26,9 +23,12 @@ open class Event1<T> : ConcurrentHashMap<Any, (T) -> Unit>() {
|
||||
}
|
||||
|
||||
class StickyEvent1<T>(private val fire: () -> T) : Event1<T>() {
|
||||
override fun put(key: Any, value: (T) -> Unit): ((T) -> Unit)? {
|
||||
val result = super.put(key, value)
|
||||
if (result == null) value(fire())
|
||||
return result
|
||||
override fun put(key: Any, value: (T) -> Unit): ((T) -> Unit)? =
|
||||
super.put(key, value).also { if (it == null) value(fire()) }
|
||||
}
|
||||
|
||||
open class Event2<T1, T2> : ConcurrentHashMap<Any, (T1, T2) -> Unit>() {
|
||||
operator fun invoke(arg1: T1, arg2: T2) {
|
||||
for ((_, handler) in this) handler(arg1, arg2)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user