Arrange the code so that if the user sends a text frame, the server shows the user's message, but if the user sends "exit" the server sends a farewell message and closes the connection.
WebSockets
Time to exit
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
}
send(Frame.Text("You enter: \"$receivedText\""))
}
frame as? Frame.Text ?: continue
close(CloseReason(CloseReason.Codes.NORMAL, "Client exit"))
val receivedText = frame.readText()
} else {
for (frame in incoming) {
if (receivedText.equals("exit", ignoreCase = true)) {
send(Frame.Text("Good bye!"))
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.