ws: send unsolicited pong control frame on connect in ws_test.v (#6010)
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…
Reference in New Issue