mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
net.websocket: make thread safe/concurrent (#18179)
This commit is contained in:
@ -50,7 +50,7 @@ fn start_server(family net.AddrFamily, listen_port int) ! {
|
||||
eprintln('> start_server family:${family} | listen_port: ${listen_port}')
|
||||
mut s := websocket.new_server(family, listen_port, '')
|
||||
// make that in execution test time give time to execute at least one time
|
||||
s.ping_interval = 1
|
||||
s.set_ping_interval(1)
|
||||
|
||||
s.on_connect(fn (mut s websocket.ServerClient) !bool {
|
||||
// here you can look att the client info and accept or not accept
|
||||
@ -80,7 +80,7 @@ fn start_server_in_thread_and_wait_till_it_is_ready_to_accept_connections(mut ws
|
||||
spawn fn [mut ws] () {
|
||||
ws.listen() or { panic('websocket server could not listen, err: ${err}') }
|
||||
}()
|
||||
for ws.state != .open {
|
||||
for ws.get_state() != .open {
|
||||
time.sleep(10 * time.millisecond)
|
||||
}
|
||||
eprintln('-----------------------------------------------------------------------------')
|
||||
|
Reference in New Issue
Block a user