add some code

This commit is contained in:
2025-09-05 13:25:11 +08:00
parent 9ff0a99e7a
commit 3cf1229a85
8911 changed files with 2535396 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
#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() 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