mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ws: send unsolicited pong control frame on connect in ws_test.v (#6010)
This commit is contained in:
parent
2f2463a04c
commit
7b630f0350
@ -590,6 +590,10 @@ pub fn (mut ws Client) read() int {
|
|||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn (mut ws Client) send_pong() int {
|
||||||
|
return ws.send_control_frame(.pong, 'PONG', [])
|
||||||
|
}
|
||||||
|
|
||||||
fn (mut ws Client) send_control_frame(code OPCode, frame_typ string, payload []byte) int {
|
fn (mut ws Client) send_control_frame(code OPCode, frame_typ string, payload []byte) int {
|
||||||
mut bytes_written := -1
|
mut bytes_written := -1
|
||||||
if ws.socket.sockfd <= 0 {
|
if ws.socket.sockfd <= 0 {
|
||||||
@ -650,4 +654,4 @@ fn (mut ws Client) send_control_frame(code OPCode, frame_typ string, payload []b
|
|||||||
return bytes_written
|
return bytes_written
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -41,7 +41,9 @@ fn ws_test(uri string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_open(mut test Test, x voidptr, ws &websocket.Client) {
|
fn on_open(mut test Test, x voidptr, mut ws &websocket.Client) {
|
||||||
|
// Send PONG only for testing porposes
|
||||||
|
ws.send_pong()
|
||||||
println('websocket opened.')
|
println('websocket opened.')
|
||||||
test.connected = true
|
test.connected = true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user