https://kotlinlang.org logo
#coroutines
Title
# coroutines
n

napperley

04/16/2019, 4:31 AM
Is it possible to have two Coroutines print to the console at the same time (in a queue), while one is reading keyboard input from the console?
o

octylFractal

04/16/2019, 4:32 AM
sure, what makes you think it wouldn't be? the system streams are already thread-safe
n

napperley

04/16/2019, 4:35 AM
Basic Websocket client that sends messages to the server and receives responses back in the console.
n

Nick

04/16/2019, 4:36 AM
A
select
might work for this.
o

octylFractal

04/16/2019, 4:39 AM
also, you do mean to make two requests here, right? not one combined websocket?
n

napperley

04/16/2019, 4:48 AM
In the example there are two WebSocket sessions.
o

octylFractal

04/16/2019, 4:51 AM
I can't see anything immediately obvious that would make this not work. assuming your
/ws/echo
endpoint doesn't echo it to all sessions though, you won't see anything. if it does, I'd have to setup the code to see what's not working
n

napperley

04/16/2019, 4:53 AM
The server will echo to all sessions pointing to the same path.
Revised version of WebSocket client example where WebSocket input/output works as expected with the console concurrently.
3 Views