You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
755 B
33 lines
755 B
#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 Start() override;
|
|
void SendAudio(const std::vector<uint8_t>& data) 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);
|
|
bool SendText(const std::string& text) override;
|
|
};
|
|
|
|
#endif
|