ci: fix vlib/x/websocket tests
parent
7c6695317c
commit
aa889b0edc
|
@ -8,7 +8,7 @@ fn echo_server(_c net.UdpConn) {
|
||||||
c.set_read_timeout(10 * time.second)
|
c.set_read_timeout(10 * time.second)
|
||||||
c.set_write_timeout(10 * time.second)
|
c.set_write_timeout(10 * time.second)
|
||||||
for {
|
for {
|
||||||
buf := []byte{ len: 100, init: 0 }
|
mut buf := []byte{ len: 100, init: 0 }
|
||||||
read, addr := c.read_into(mut buf) or {
|
read, addr := c.read_into(mut buf) or {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ fn echo() ? {
|
||||||
|
|
||||||
c.write_string(data)?
|
c.write_string(data)?
|
||||||
|
|
||||||
buf := []byte{ len: 100, init: 0 }
|
mut buf := []byte{ len: 100, init: 0 }
|
||||||
read, addr := c.read_into(mut buf)?
|
read, addr := c.read_into(mut buf)?
|
||||||
|
|
||||||
assert read == data.len
|
assert read == data.len
|
||||||
|
@ -71,4 +71,4 @@ fn test_udp() {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
test_udp()
|
test_udp()
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ pub fn (mut s Server) listen() ? {
|
||||||
s.set_state(.open)
|
s.set_state(.open)
|
||||||
go s.handle_ping()
|
go s.handle_ping()
|
||||||
for {
|
for {
|
||||||
c := s.accept_new_client() or {
|
mut c := s.accept_new_client() or {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
go s.serve_client(mut c)
|
go s.serve_client(mut c)
|
||||||
|
@ -104,7 +104,7 @@ fn (mut s Server) serve_client(mut c Client) ? {
|
||||||
defer {
|
defer {
|
||||||
c.logger.debug('server-> End serve client ($c.id)')
|
c.logger.debug('server-> End serve client ($c.id)')
|
||||||
}
|
}
|
||||||
handshake_response, server_client := s.handle_server_handshake(mut c)?
|
mut handshake_response, mut server_client := s.handle_server_handshake(mut c)?
|
||||||
accept := s.send_connect_event(mut server_client)?
|
accept := s.send_connect_event(mut server_client)?
|
||||||
if !accept {
|
if !accept {
|
||||||
s.logger.debug('server-> client not accepted')
|
s.logger.debug('server-> client not accepted')
|
||||||
|
@ -148,7 +148,7 @@ fn (mut s Server) setup_callbacks(mut sc ServerClient) {
|
||||||
lock {
|
lock {
|
||||||
sc.server.clients.delete(sc.client.id)
|
sc.server.clients.delete(sc.client.id)
|
||||||
}
|
}
|
||||||
}, mut sc)
|
}, sc)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut s Server) accept_new_client() ?&Client {
|
fn (mut s Server) accept_new_client() ?&Client {
|
||||||
|
|
Loading…
Reference in New Issue