2020-07-03 01:45:18 +02:00
|
|
|
/*
|
2020-08-19 15:29:35 +02:00
|
|
|
* Copyright 2020 dorkbox, llc
|
2020-07-03 01:45:18 +02:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2020-08-19 15:29:35 +02:00
|
|
|
*
|
2020-07-03 01:45:18 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2020-08-31 14:52:42 +02:00
|
|
|
package dorkboxTest.network.rmi.cows
|
2020-07-03 01:45:18 +02:00
|
|
|
|
2020-08-22 22:58:03 +02:00
|
|
|
import dorkbox.network.connection.Connection
|
2020-08-18 23:18:27 +02:00
|
|
|
import kotlinx.coroutines.delay
|
|
|
|
|
2020-08-26 15:34:04 +02:00
|
|
|
open class TestCowImpl(val id: Int) : TestCowBaseImpl(), TestCow {
|
2020-07-03 01:45:18 +02:00
|
|
|
|
|
|
|
private var moos = 0
|
2020-08-13 14:38:53 +02:00
|
|
|
|
2020-07-03 01:45:18 +02:00
|
|
|
override fun moo() {
|
2020-08-22 22:58:03 +02:00
|
|
|
throw RuntimeException("Should never be executed!")
|
|
|
|
}
|
|
|
|
|
|
|
|
fun moo(connection: Connection) {
|
2020-07-03 01:45:18 +02:00
|
|
|
moos++
|
2020-08-22 22:58:03 +02:00
|
|
|
connection.logger.error("Moo! $moos")
|
2020-07-03 01:45:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun moo(value: String) {
|
2020-08-22 22:58:03 +02:00
|
|
|
throw RuntimeException("Should never be executed!")
|
|
|
|
}
|
|
|
|
|
2023-02-16 23:23:47 +01:00
|
|
|
override fun mooTwo(value: String): String {
|
2023-02-27 11:28:24 +01:00
|
|
|
// println(value)
|
2023-02-24 16:35:00 +01:00
|
|
|
return "moo-two: $value"
|
2023-02-16 23:23:47 +01:00
|
|
|
}
|
|
|
|
|
2020-08-22 22:58:03 +02:00
|
|
|
fun moo(connection: Connection, value: String) {
|
2020-07-03 01:45:18 +02:00
|
|
|
moos += 2
|
2020-08-22 22:58:03 +02:00
|
|
|
connection.logger.error("Moo! $moos: $value")
|
2020-07-03 01:45:18 +02:00
|
|
|
}
|
|
|
|
|
2020-08-22 22:58:03 +02:00
|
|
|
override suspend fun moo(value: String, delay: Long) {
|
|
|
|
throw RuntimeException("Should never be executed!")
|
|
|
|
}
|
|
|
|
|
|
|
|
suspend fun moo(connection: Connection, value: String, delay: Long) {
|
2020-07-03 01:45:18 +02:00
|
|
|
moos += 4
|
2020-08-22 22:58:03 +02:00
|
|
|
connection.logger.error("Moo! $moos: $value ($delay)")
|
|
|
|
delay(delay)
|
2020-07-03 01:45:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun id(): Int {
|
|
|
|
return id
|
|
|
|
}
|
|
|
|
|
2020-08-22 22:58:03 +02:00
|
|
|
override suspend fun slow(): Float {
|
|
|
|
throw RuntimeException("Should never be executed!")
|
|
|
|
}
|
|
|
|
|
|
|
|
suspend fun slow(connection: Connection): Float {
|
|
|
|
connection.logger.error("Slowdown!!")
|
|
|
|
delay(2000)
|
2020-07-03 01:45:18 +02:00
|
|
|
return 123.0f
|
|
|
|
}
|
|
|
|
|
2020-08-18 23:18:27 +02:00
|
|
|
override suspend fun withSuspend(value: String, v2: Int) {
|
2021-07-02 11:40:20 +02:00
|
|
|
throw RuntimeException("'$value : $v2' should never be executed!")
|
2020-08-22 22:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
suspend fun withSuspend(connection: Connection, value: String, v2: Int) {
|
2021-07-02 11:40:20 +02:00
|
|
|
connection.logger.error("Suspending '$value : $v2'!")
|
2020-08-18 23:18:27 +02:00
|
|
|
delay(2000)
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun withSuspendAndReturn(value: String, v2: Int): Int {
|
2021-07-02 11:40:20 +02:00
|
|
|
throw RuntimeException("'$value : $v2' should never be executed!")
|
2020-08-22 22:58:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
suspend fun withSuspendAndReturn(connection: Connection, value: String, v2: Int): Int {
|
2021-07-02 11:40:20 +02:00
|
|
|
connection.logger.error("Suspending '$value' with return!")
|
2020-08-18 23:18:27 +02:00
|
|
|
delay(2000)
|
|
|
|
return v2
|
|
|
|
}
|
|
|
|
|
2020-07-03 01:45:18 +02:00
|
|
|
override fun equals(other: Any?): Boolean {
|
|
|
|
if (this === other) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
if (other == null || javaClass != other.javaClass) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
val that = other as TestCowImpl
|
|
|
|
return id == that.id
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun hashCode(): Int {
|
|
|
|
return id
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun toString(): String {
|
|
|
|
return "Tada! This is a remote object!"
|
|
|
|
}
|
|
|
|
}
|