Skip to content

Commit

Permalink
ws: add support responding CRLF pong to ping
Browse files Browse the repository at this point in the history
  • Loading branch information
davehorton committed Sep 3, 2024
1 parent f8ed764 commit 80b0aa6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libsofia-sip-ua/tport/tport_type_ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,16 @@ int tport_recv_stream_ws(tport_t *self)
return 0;
}

// DH: Check for "ping" message (CRLF)
if (N == 2 || N == 4) {
if ((data[0] == '\r' && data[1] == '\n') &&
(N == 2 || (data[2] == '\r' && data[3] == '\n'))) {
// "ping" message detected, send "pong"
tport_ws_pong(self);
return 1;
}
}

veclen = tport_recv_iovec(self, &self->tp_msg, iovec, N, 0);
if (veclen < 0)
return -1;
Expand Down Expand Up @@ -696,4 +706,4 @@ void tport_ws_timer(tport_t *self, su_time_t now)
tport_keepalive_timer(self, now);
}
tport_base_timer(self, now);
}
}

0 comments on commit 80b0aa6

Please sign in to comment.