mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
net: use mut and refs as receivers consistently (#8205)
This commit is contained in:
@@ -86,7 +86,7 @@ fn (mut ws Client) shutdown_socket() ? {
|
||||
}
|
||||
|
||||
// dial_socket connects tcp socket and initializes default configurations
|
||||
fn (mut ws Client) dial_socket() ?net.TcpConn {
|
||||
fn (mut ws Client) dial_socket() ?&net.TcpConn {
|
||||
tcp_address := '$ws.uri.hostname:$ws.uri.port'
|
||||
mut t := net.dial_tcp(tcp_address) ?
|
||||
optval := int(1)
|
||||
|
||||
@@ -30,7 +30,7 @@ pub:
|
||||
uri Uri // uri of current connection
|
||||
id string // unique id of client
|
||||
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
|
||||
panic_on_callback bool // set to true of callbacks can panic
|
||||
state State // current state of connection
|
||||
@@ -75,6 +75,7 @@ pub enum OPCode {
|
||||
pub fn new_client(address string) ?&Client {
|
||||
uri := parse_uri(address) ?
|
||||
return &Client{
|
||||
conn: 0
|
||||
is_server: false
|
||||
ssl_conn: openssl.new_ssl_conn()
|
||||
is_ssl: address.starts_with('wss')
|
||||
|
||||
@@ -9,8 +9,8 @@ import rand
|
||||
// Server represents a websocket server connection
|
||||
pub struct Server {
|
||||
mut:
|
||||
logger &log.Log // logger used to log
|
||||
ls net.TcpListener // listener used to get incoming connection to socket
|
||||
logger &log.Log // logger used to log
|
||||
ls &net.TcpListener // listener used to get incoming connection to socket
|
||||
accept_client_callbacks []AcceptClientFn // accept client callback functions
|
||||
message_callbacks []MessageEventHandler // new message callback functions
|
||||
close_callbacks []CloseEventHandler // close message callback functions
|
||||
@@ -36,6 +36,7 @@ pub mut:
|
||||
// new_server instance a new websocket server on provided port and route
|
||||
pub fn new_server(port int, route string) &Server {
|
||||
return &Server{
|
||||
ls: 0
|
||||
port: port
|
||||
logger: &log.Log{
|
||||
level: .info
|
||||
|
||||
Reference in New Issue
Block a user