26 lines
465 B
Kotlin
26 lines
465 B
Kotlin
package drills.drill02.exercise1
|
|
|
|
import util.rmi.Client
|
|
|
|
fun main() {
|
|
Client(clientHandler).start()
|
|
}
|
|
|
|
val clientHandler = {
|
|
val chat = Client.lookup("chat") as RemoteObservable
|
|
|
|
val observer: RemoteObserver = ChatObserver()
|
|
chat.attach(observer)
|
|
|
|
print("Send> ")
|
|
var line = readLine() ?: "."
|
|
|
|
while (line != ".") {
|
|
chat.notify(line)
|
|
println("Send> ")
|
|
line = readLine() ?: "."
|
|
}
|
|
|
|
chat.detach(observer)
|
|
}
|