1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ci: run vfmt over websocket_client.v and websocket_server.v

This commit is contained in:
Delyan Angelov
2020-12-28 07:13:25 +02:00
parent bd67b647f2
commit b65353794c
2 changed files with 25 additions and 27 deletions

View File

@ -31,7 +31,8 @@ pub:
id string // unique id of client id string // unique id of client
pub mut: pub mut:
conn net.TcpConn // underlying TCP socket connection conn net.TcpConn // underlying TCP socket connection
nonce_size int = 16 // size of nounce used for masking // size of nounce used for masking
nonce_size int = 16
panic_on_callback bool // set to true of callbacks can panic panic_on_callback bool // set to true of callbacks can panic
state State // current state of connection state State // current state of connection
logger &log.Log // logger used to log messages logger &log.Log // logger used to log messages

View File

@ -20,7 +20,8 @@ pub:
port int // port used as listen to incoming connections port int // port used as listen to incoming connections
is_ssl bool // true if secure connection (not supported yet on server) is_ssl bool // true if secure connection (not supported yet on server)
pub mut: pub mut:
ping_interval int = 30 // interval for sending ping to clients (seconds) ping_interval int = 30
// interval for sending ping to clients (seconds)
state State // current state of connection state State // current state of connection
} }
@ -57,9 +58,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 {
mut 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)
} }
s.logger.info('websocket server: end listen on port $s.port') s.logger.info('websocket server: end listen on port $s.port')
@ -88,9 +87,7 @@ fn (mut s Server) handle_ping() {
} }
if (time.now().unix - c.client.last_pong_ut) > s.ping_interval * 2 { if (time.now().unix - c.client.last_pong_ut) > s.ping_interval * 2 {
clients_to_remove << c.client.id clients_to_remove << c.client.id
c.client.close(1000, 'no pong received') or { c.client.close(1000, 'no pong received') or { continue }
continue
}
} }
} }
} }