return process_text_message(instance, payload, payload_len);
}
- if (opcode == AST_WEBSOCKET_OPCODE_PING || opcode == AST_WEBSOCKET_OPCODE_PONG) {
+ /*
+ * PINGs and PONGs will have been handled by res_http_websocket.
+ * We also need to ignore CONTINUATION frames as they will be accumulated
+ * by res_http_websocket until the threshold set in websocket_handoff_to_channel()
+ * is reached, then it will send us a TEXT or BINARY frame.
+ */
+ if (opcode == AST_WEBSOCKET_OPCODE_PING || opcode == AST_WEBSOCKET_OPCODE_PONG
+ || opcode == AST_WEBSOCKET_OPCODE_CONTINUATION) {
return 0;
}
ast_log(LOG_WARNING, "Failed to set TCP_NODELAY on websocket connection: %s\n", strerror(errno));
}
+ /*
+ * Tell res_http_websocket to accumulate incoming WebSocket CONTINUATION frames
+ * into chunks of 1024 bytes and send us a TEXT or BINARY frame when the threshold
+ * is reached.
+ */
+ ast_websocket_reconstruct_enable(instance->websocket, 1024);
+
ast_channel_set_fd(instance->channel, WS_WEBSOCKET_FDNO, ast_websocket_fd(instance->websocket));
res = send_event(instance, MEDIA_START);