ws: send unsolicited pong control frame on connect in ws_test.v (#6010)

pull/6018/head
Carlos Esquerdo Bernat 2020-07-29 17:11:24 +02:00 committed by GitHub
parent 2f2463a04c
commit 7b630f0350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -590,6 +590,10 @@ pub fn (mut ws Client) read() int {
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 {
mut bytes_written := -1
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
}
}
}
}

View File

@ -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.')
test.connected = true
}