You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Labels.kt 523B

12345678910111213141516
  1. package com.dmdirc.ktirc.util
  2. import com.dmdirc.ktirc.IrcClient
  3. import com.dmdirc.ktirc.sasl.toBase64
  4. import java.time.ZoneOffset
  5. internal var generateLabel = { ircClient: IrcClient ->
  6. val time = currentTimeProvider().toEpochSecond(ZoneOffset.UTC)
  7. val counter = ircClient.serverState.labelCounter.incrementAndGet()
  8. ByteArray(6) {
  9. when {
  10. it < 3 -> ((time shr it) and 0xff).toByte()
  11. else -> ((counter shr (it - 3)) and 0xff).toByte()
  12. }
  13. }.toBase64()
  14. }