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

net.websocket: swap unsafe use of nil for a safe default value (#15836)

This commit is contained in:
Alfie Ranstead
2022-09-22 06:00:03 +01:00
committed by GitHub
parent 41dbd12bc4
commit 27305d1a5f
5 changed files with 84 additions and 6 deletions

View File

@ -36,11 +36,14 @@ pub mut:
header http.Header // headers that will be passed when connecting
conn &net.TcpConn = unsafe { nil } // underlying TCP socket connection
nonce_size int = 16 // size of nounce used for masking
panic_on_callback bool // set to true of callbacks can panic
state State // current state of connection
logger &log.Logger = unsafe { nil } // logger used to log messages
resource_name string // name of current resource
last_pong_ut i64 // last time in unix time we got a pong message
panic_on_callback bool // set to true of callbacks can panic
state State // current state of connection
// logger used to log messages
logger &log.Logger = &log.Logger(&log.Log{
level: .info
})
resource_name string // name of current resource
last_pong_ut i64 // last time in unix time we got a pong message
}
// Flag represents different types of headers in websocket handshake

View File

@ -9,7 +9,9 @@ import rand
// Server represents a websocket server connection
pub struct Server {
mut:
logger &log.Logger = unsafe { nil } // logger used to log
logger &log.Logger = &log.Logger(&log.Log{
level: .info
})
ls &net.TcpListener = unsafe { nil } // listener used to get incoming connection to socket
accept_client_callbacks []AcceptClientFn // accept client callback functions
message_callbacks []MessageEventHandler // new message callback functions