mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
x.websocket: server broadcast plus examples (#7922)
This commit is contained in:
@ -333,11 +333,9 @@ pub fn (mut ws Client) close(code int, message string) ? {
|
||||
close_frame[i + 2] = message[i]
|
||||
}
|
||||
ws.send_control_frame(.close, 'CLOSE', close_frame) ?
|
||||
ws.send_close_event(code, message)
|
||||
unsafe { close_frame.free() }
|
||||
} else {
|
||||
ws.send_control_frame(.close, 'CLOSE', []) ?
|
||||
ws.send_close_event(code, '')
|
||||
}
|
||||
ws.fragments = []
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import rand
|
||||
// Server represents a websocket server connection
|
||||
pub struct Server {
|
||||
mut:
|
||||
clients map[string]&ServerClient // clients connected to this server
|
||||
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
|
||||
@ -20,8 +19,8 @@ pub:
|
||||
port int // port used as listen to incoming connections
|
||||
is_ssl bool // true if secure connection (not supported yet on server)
|
||||
pub mut:
|
||||
ping_interval int = 30
|
||||
// interval for sending ping to clients (seconds)
|
||||
clients map[string]&ServerClient // clients connected to this server
|
||||
ping_interval int = 30 // interval for sending ping to clients (seconds)
|
||||
state State // current state of connection
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user