kodi
WebSocketV8.h
1 /*
2  * Copyright (C) 2011-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "WebSocket.h"
12 
13 #include <string>
14 
15 class CWebSocketV8 : public CWebSocket
16 {
17 public:
18  CWebSocketV8() { m_version = 8; }
19 
20  bool Handshake(const char* data, size_t length, std::string &response) override;
21  const CWebSocketFrame* Ping(const char* data = NULL) const override { return new CWebSocketFrame(WebSocketPing, data); }
22  const CWebSocketFrame* Pong(const char* data, uint32_t length) const override
23  {
24  return new CWebSocketFrame(WebSocketPong, data, length);
25  }
26  const CWebSocketFrame* Close(WebSocketCloseReason reason = WebSocketCloseNormal, const std::string &message = "") override;
27  void Fail() override;
28 
29 protected:
30  CWebSocketFrame* GetFrame(const char* data, uint64_t length) override;
31  CWebSocketFrame* GetFrame(WebSocketFrameOpcode opcode, const char* data = NULL, uint32_t length = 0, bool final = true, bool masked = false, int32_t mask = 0, int8_t extension = 0) override;
32  CWebSocketMessage* GetMessage() override;
33  virtual const CWebSocketFrame* close(WebSocketCloseReason reason = WebSocketCloseNormal, const std::string &message = "");
34 
35  std::string calculateKey(const std::string &key);
36 };
Definition: WebSocket.h:107
Definition: WebSocket.h:87
Definition: WebSocket.h:49
Definition: WebSocketV8.h:15