5#ifndef PT_HTTP_WEBSOCKETMESSAGE_H
6#define PT_HTTP_WEBSOCKETMESSAGE_H
8#include <Pt/Http/Api.h>
9#include <Pt/NonCopyable.h>
19class WebSocketChannel;
25class WebSocketMessageBuffer :
public std::streambuf
29 WebSocketMessageBuffer();
32 ~WebSocketMessageBuffer();
38 void discard(std::size_t n);
41 std::size_t size()
const;
44 const char* data()
const;
47 virtual int_type overflow(int_type ch);
49 virtual std::streamsize xsputn(
const char* data, std::streamsize n);
51 virtual int_type underflow();
54 std::vector<char> _payload;
111 friend class WebSocketChannel;
171 WebSocketMessageBuffer& buffer()
175 void setTypeFromEngine(Type type);
178 void setBuffer(std::streambuf& sb);
182 WebSocketMessageBuffer _buf;
Type
Data type of a WebSocket message.
Definition WebSocketMessage.h:125
@ Text
UTF-8 text.
Definition WebSocketMessage.h:127
@ Unknown
No data type yet.
Definition WebSocketMessage.h:126
@ Binary
Binary payload.
Definition WebSocketMessage.h:128
WebSocketMessage()
Creates an empty message.
void discard()
Drops the buffered body and leaves the type.
void setType(Type type)
Sets the data type of an outgoing message.
void discard(std::size_t n)
Drops up to n buffered body bytes and leaves the type.
std::iostream & body()
Returns the payload stream.
Definition WebSocketMessage.h:144
std::size_t pending() const
Returns how many payload bytes are waiting to be sent.
void clear()
Drops the buffered body and sets the type to Unknown.
std::size_t available() const
Returns how many payload bytes can be read.
Type type() const
Returns the data type of this message.
Definition WebSocketMessage.h:133
~WebSocketMessage()
Destroys the message.
NonCopyable()
Default constructor.
Definition NonCopyable.h:63
HTTP clients and servers.
Core module.
Definition Allocator.h:33