forked from xiaozhi/xiaozhi-esp32
add websocket protocol
This commit is contained in:
33
main/protocols/websocket_protocol.h
Normal file
33
main/protocols/websocket_protocol.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#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();
|
||||
|
||||
void SendAudio(const std::string& data) override;
|
||||
void SendText(const std::string& text) override;
|
||||
void SendState(const std::string& state) override;
|
||||
void SendAbort() override;
|
||||
bool OpenAudioChannel() override;
|
||||
void CloseAudioChannel() override;
|
||||
bool IsAudioChannelOpened() const override;
|
||||
|
||||
private:
|
||||
EventGroupHandle_t event_group_handle_;
|
||||
WebSocket* websocket_ = nullptr;
|
||||
|
||||
void ParseServerHello(const cJSON* root);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user