mirror of
https://github.com/78/xiaozhi-esp32.git
synced 2026-02-13 15:38:08 +00:00
* Enhance memory management in asset download and OTA processes by replacing static buffer allocations with dynamic memory allocation using heap capabilities. Update SPIRAM configuration values for improved memory usage. Add logging for error handling in buffer allocation failures. Introduce a new parameter in CloseAudioChannel to control goodbye message sending in MQTT and WebSocket protocols. * Update component versions in idf_component.yml and refactor GIF decoder functions for improved performance. Bump versions for audio effects, audio codec, LED strip, and other dependencies. Change GIF read and seek functions to inline for optimization. * Update language files to include new phrases for flight mode and connection status across multiple locales. Added translations for "FLIGHT_MODE_ON", "FLIGHT_MODE_OFF", "CONNECTION_SUCCESSFUL", and "MODEM_INIT_ERROR" in various languages, enhancing user experience and localization support. * fix wechat display
35 lines
851 B
C++
35 lines
851 B
C++
#ifndef _WEBSOCKET_PROTOCOL_H_
|
|
#define _WEBSOCKET_PROTOCOL_H_
|
|
|
|
|
|
#include "protocol.h"
|
|
|
|
#include <web_socket.h>
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/event_groups.h>
|
|
|
|
#define WEBSOCKET_PROTOCOL_SERVER_HELLO_EVENT (1 << 0)
|
|
|
|
class WebsocketProtocol : public Protocol {
|
|
public:
|
|
WebsocketProtocol();
|
|
~WebsocketProtocol();
|
|
|
|
bool Start() override;
|
|
bool SendAudio(std::unique_ptr<AudioStreamPacket> packet) override;
|
|
bool OpenAudioChannel() override;
|
|
void CloseAudioChannel(bool send_goodbye = true) override;
|
|
bool IsAudioChannelOpened() const override;
|
|
|
|
private:
|
|
EventGroupHandle_t event_group_handle_;
|
|
std::unique_ptr<WebSocket> websocket_;
|
|
int version_ = 1;
|
|
|
|
void ParseServerHello(const cJSON* root);
|
|
bool SendText(const std::string& text) override;
|
|
std::string GetHelloMessage();
|
|
};
|
|
|
|
#endif
|