mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
Core: WebSocket improvements
git-svn-id: svn://ultimatepp.org/upp/trunk@11798 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
7d44556c1a
commit
0f93a62163
3 changed files with 55 additions and 22 deletions
|
|
@ -607,6 +607,7 @@ class WebSocket {
|
|||
String host;
|
||||
IpAddrInfo addrinfo;
|
||||
bool ssl;
|
||||
String request_header;
|
||||
|
||||
String data;
|
||||
int data_pos;
|
||||
|
|
@ -646,6 +647,8 @@ class WebSocket {
|
|||
CLOSE = 0x8,
|
||||
PING = 0x9,
|
||||
PONG = 0xa,
|
||||
|
||||
MASK = 0x80,
|
||||
};
|
||||
|
||||
void Clear();
|
||||
|
|
@ -667,13 +670,14 @@ class WebSocket {
|
|||
|
||||
int GetFinIndex() const;
|
||||
|
||||
void SendRaw(int hdr, const String& data);
|
||||
void SendRaw(int hdr, const String& data, dword mask = 0);
|
||||
void Do0();
|
||||
|
||||
static String FormatBlock(const String& s);
|
||||
|
||||
public:
|
||||
WebSocket& NonBlocking(bool b = true) { socket->Timeout(b ? 0 : Null); return *this; }
|
||||
WebSocket& RequestHeader(const String& s) { request_header = s; return *this; }
|
||||
|
||||
bool IsBlocking() const { return IsNull(socket->GetTimeout()); }
|
||||
|
||||
|
|
@ -691,6 +695,7 @@ public:
|
|||
bool IsBinary() const { return current_opcode & BINARY; }
|
||||
|
||||
void SendText(const String& data) { SendRaw(FIN|TEXT, data); }
|
||||
void SendTextMasked(const String& data) { SendRaw(FIN|TEXT, data, MASK); }
|
||||
void SendBinary(const String& data) { SendRaw(FIN|BINARY, data); }
|
||||
void Ping(const String& data) { SendRaw(FIN|PING, data); }
|
||||
|
||||
|
|
@ -699,7 +704,7 @@ public:
|
|||
void Continue(const String& data) { SendRaw(0, data); }
|
||||
void Fin(const String& data) { SendRaw(FIN, data); }
|
||||
|
||||
void Close(const String& msg = Null);
|
||||
void Close(const String& msg = Null, bool wait_reply = false);
|
||||
bool IsOpen() const { return socket->IsOpen(); }
|
||||
bool IsClosed() const { return !IsOpen(); }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue