mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Core: WebSocket fixed spelling 'Recieve'
git-svn-id: svn://ultimatepp.org/upp/trunk@8781 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
7434a3160b
commit
baf37eb94b
3 changed files with 119 additions and 115 deletions
|
|
@ -582,9 +582,9 @@ public:
|
|||
bool WebAccept(TcpSocket& socket, HttpHeader& hdr);
|
||||
bool WebAccept(TcpSocket& socket);
|
||||
|
||||
bool RecieveRaw();
|
||||
String Recieve();
|
||||
|
||||
bool ReceiveRaw();
|
||||
String Receive();
|
||||
|
||||
bool IsFin() { return opcode & FIN; }
|
||||
int GetOpCode() const { return opcode & 15; }
|
||||
bool IsText() const { return GetOpCode() == TEXT; }
|
||||
|
|
@ -611,6 +611,10 @@ public:
|
|||
WebSocket& MaxLen(int64 maxlen_) { maxlen = maxlen_; return *this; }
|
||||
|
||||
WebSocket() { Reset(); }
|
||||
|
||||
// keep missspelled method names
|
||||
bool RecieveRaw() { return ReceiveRaw(); }
|
||||
String Recieve() { return Receive(); }
|
||||
};
|
||||
|
||||
void ParseProxyUrl(const char *p, String& proxy_host, int& proxy_port);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ int64 WebSocket::ReadLen(int n)
|
|||
return len;
|
||||
}
|
||||
|
||||
bool WebSocket::RecieveRaw()
|
||||
bool WebSocket::ReceiveRaw()
|
||||
{
|
||||
if(IsError())
|
||||
return false;
|
||||
|
|
@ -59,19 +59,19 @@ bool WebSocket::RecieveRaw()
|
|||
socket->Get(key, 4);
|
||||
|
||||
if(IsError()) {
|
||||
socket->SetSockError("websocket recieve", ERROR_DATA, "Invalid data");
|
||||
socket->SetSockError("websocket receive", ERROR_DATA, "Invalid data");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(len > maxlen || len < 0) {
|
||||
socket->SetSockError("websocket recieve", ERROR_LEN_LIMIT, "Frame limit exceeded, size " + AsString(len));
|
||||
socket->SetSockError("websocket receive", ERROR_LEN_LIMIT, "Frame limit exceeded, size " + AsString(len));
|
||||
return false;
|
||||
}
|
||||
|
||||
StringBuffer frame((int)len); // TODO int64
|
||||
char *buffer = ~frame;
|
||||
if(!socket->GetAll(buffer, (int)len)) {
|
||||
socket->SetSockError("websocket recieve", ERROR_DATA, "Invalid data");
|
||||
socket->SetSockError("websocket receive", ERROR_DATA, "Invalid data");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -83,9 +83,9 @@ bool WebSocket::RecieveRaw()
|
|||
return true;
|
||||
}
|
||||
|
||||
String WebSocket::Recieve()
|
||||
String WebSocket::Receive()
|
||||
{
|
||||
LLOG("WebSocket::Recieve");
|
||||
LLOG("WebSocket::Receive");
|
||||
for(;;) {
|
||||
if(!RecieveRaw()) {
|
||||
LLOG("WebSocket::Recieve failed");
|
||||
|
|
@ -99,7 +99,7 @@ String WebSocket::Recieve()
|
|||
break;
|
||||
}
|
||||
}
|
||||
LLOG("WebSocket::Recieve len: " << data.GetLength());
|
||||
LLOG("WebSocket::Receive len: " << data.GetLength());
|
||||
return data;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,126 +9,126 @@ topic "WebSocket";
|
|||
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
|
||||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[{_}%EN-US
|
||||
[ {{10000@(113.42.0) [s0; [*@7;4 WebSocket]]}}&]
|
||||
[s3;%- &]
|
||||
[s1;:WebSocket`:`:class:%- [@(0.0.255)3 class][3 _][*3 WebSocket]&]
|
||||
[s2; Provides the WebSocket protocol support. WebSocket is a wrapper
|
||||
[{_}
|
||||
[ {{10000@(113.42.0) [s0;%% [*@7;4 WebSocket]]}}&]
|
||||
[s3; &]
|
||||
[s1;:WebSocket`:`:class: [@(0.0.255)3 class][3 _][*3 WebSocket]&]
|
||||
[s2;%% Provides the WebSocket protocol support. WebSocket is a wrapper
|
||||
over existing TcpSocket connection, which performs server handshake
|
||||
by calling WebAccept method.&]
|
||||
[s0;i448;a25;kKO9;:noref:@(0.0.255)%- &]
|
||||
[ {{10000F(128)G(128)@1 [s0; [* Public Method List]]}}&]
|
||||
[s3;%- &]
|
||||
[s5;:WebSocket`:`:WebAccept`(TcpSocket`&`,HttpHeader`&`):%- [@(0.0.255) bool]_[* WebAccep
|
||||
t]([_^TcpSocket^ TcpSocket][@(0.0.255) `&]_[*@3 socket], [_^HttpHeader^ HttpHeader][@(0.0.255) `&
|
||||
[s0;i448;a25;kKO9;:noref:@(0.0.255) &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Public Method List]]}}&]
|
||||
[s3; &]
|
||||
[s5;:WebSocket`:`:WebAccept`(TcpSocket`&`,HttpHeader`&`): [@(0.0.255) bool]_[* WebAccept](
|
||||
[_^TcpSocket^ TcpSocket][@(0.0.255) `&]_[*@3 socket], [_^HttpHeader^ HttpHeader][@(0.0.255) `&
|
||||
]_[*@3 hdr])&]
|
||||
[s2; Attempts to open websocket connection with [%-*@3 socket], [%-*@3 hdr]
|
||||
[s2;%% Attempts to open websocket connection with [%-*@3 socket], [%-*@3 hdr]
|
||||
is HTTP header read from socket `- prereading allows to distinguish
|
||||
between websocket and normal HTTP connection to server.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:WebSocket`:`:WebAccept`(TcpSocket`&`):%- [@(0.0.255) bool]_[* WebAccept]([_^TcpSocket^ T
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:WebAccept`(TcpSocket`&`): [@(0.0.255) bool]_[* WebAccept]([_^TcpSocket^ T
|
||||
cpSocket][@(0.0.255) `&]_[*@3 socket])&]
|
||||
[s2; Reads HTTP header from [%-*@3 socket] and calls other WebAccept
|
||||
[s2;%% Reads HTTP header from [%-*@3 socket] and calls other WebAccept
|
||||
variant.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:WebSocket`:`:ReceiveRaw`(`): [@(0.0.255) bool]_[* ReceiveRaw]()&]
|
||||
[s2;%% Recieves the message. This variant does not automatically
|
||||
handle PING and CLOSE messages. Returns true on success.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:RecieveRaw`(`):%- [@(0.0.255) bool]_[* RecieveRaw]()&]
|
||||
[s2; Recieves the message. This variant does not automatically handle
|
||||
PING and CLOSE messages. Returns true on success.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:Recieve`(`):%- [_^String^ String]_[* Recieve]()&]
|
||||
[s2; Recieves the message. PING and CLOSE messages are handled and
|
||||
are not returned; PING message is replied with PONG and not reported
|
||||
to client `- Recieve does not return and waits for the next message,
|
||||
CLOSE is replied by CLOSE and Recieve returns. Returns the content
|
||||
of message recieved or String`::GetVoid() if there was none. Note:
|
||||
If WaitRead was used to wait for read on socket before calling
|
||||
Recieve, returning String`::GetVoid() means that connection was
|
||||
broken.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:IsFin`(`):%- [@(0.0.255) bool]_[* IsFin]()&]
|
||||
[s2; Returns true if the last message was marked as final.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:GetOpCode`(`)const:%- [@(0.0.255) int]_[* GetOpCode]()_[@(0.0.255) const]&]
|
||||
[s2; Returns the websocket opcode of the last recieved message.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:IsText`(`)const:%- [@(0.0.255) bool]_[* IsText]()_[@(0.0.255) const]&]
|
||||
[s2; Returns true if the last message recieved was text.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:IsBinary`(`)const:%- [@(0.0.255) bool]_[* IsBinary]()_[@(0.0.255) const]&]
|
||||
[s2; Returns true if the last message recieved was binary.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:IsClosed`(`)const:%- [@(0.0.255) bool]_[* IsClosed]()_[@(0.0.255) const]&]
|
||||
[s2; Returns true if CLOSE message was recieved.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:GetData`(`)const:%- [_^String^ String]_[* GetData]()_[@(0.0.255) const]&]
|
||||
[s2; Returns the content of the last message.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:SendRaw`(int`,const void`*`,int64`):%- [@(0.0.255) bool]_[* SendRaw]([@(0.0.255) i
|
||||
[s5;:Upp`:`:WebSocket`:`:Receive`(`): [_^Upp`:`:String^ String]_[* Receive]()&]
|
||||
[s2;%% Recieves the message. PING and CLOSE messages are handled
|
||||
and are not returned; PING message is replied with PONG and not
|
||||
reported to client `- Recieve does not return and waits for the
|
||||
next message, CLOSE is replied by CLOSE and Recieve returns.
|
||||
Returns the content of message recieved or String`::GetVoid()
|
||||
if there was none. Note: If WaitRead was used to wait for read
|
||||
on socket before calling Recieve, returning String`::GetVoid()
|
||||
means that connection was broken.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:WebSocket`:`:IsFin`(`): [@(0.0.255) bool]_[* IsFin]()&]
|
||||
[s2;%% Returns true if the last message was marked as final.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:WebSocket`:`:GetOpCode`(`)const: [@(0.0.255) int]_[* GetOpCode]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns the websocket opcode of the last recieved message.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:WebSocket`:`:IsText`(`)const: [@(0.0.255) bool]_[* IsText]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns true if the last message recieved was text.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:WebSocket`:`:IsBinary`(`)const: [@(0.0.255) bool]_[* IsBinary]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns true if the last message recieved was binary.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:WebSocket`:`:IsClosed`(`)const: [@(0.0.255) bool]_[* IsClosed]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns true if CLOSE message was recieved.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:WebSocket`:`:GetData`(`)const: [_^String^ String]_[* GetData]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns the content of the last message.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:WebSocket`:`:SendRaw`(int`,const void`*`,int64`): [@(0.0.255) bool]_[* SendRaw]([@(0.0.255) i
|
||||
nt]_[*@3 hdr], [@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data], [_^int64^ int64]_[*@3 len])
|
||||
&]
|
||||
[s2; Sends the message, [%-*@3 hdr] is used as the first byte of websocket
|
||||
protocol. Returns true on success.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:SendText`(const void`*`,int64`,bool`):%- [@(0.0.255) bool]_[* SendText](
|
||||
[@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data], [_^int64^ int64]_[*@3 len],
|
||||
[@(0.0.255) bool]_[*@3 fin]_`=_[@(0.0.255) true])&]
|
||||
[s5;:WebSocket`:`:SendText`(const String`&`,bool`):%- [@(0.0.255) bool]_[* SendText]([@(0.0.255) c
|
||||
[s2;%% Sends the message, [%-*@3 hdr] is used as the first byte of
|
||||
websocket protocol. Returns true on success.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:WebSocket`:`:SendText`(const void`*`,int64`,bool`): [@(0.0.255) bool]_[* SendText]([@(0.0.255) c
|
||||
onst]_[@(0.0.255) void]_`*[*@3 data], [_^int64^ int64]_[*@3 len], [@(0.0.255) bool]_[*@3 fin]_
|
||||
`=_[@(0.0.255) true])&]
|
||||
[s5;:WebSocket`:`:SendText`(const String`&`,bool`): [@(0.0.255) bool]_[* SendText]([@(0.0.255) c
|
||||
onst]_[_^String^ String][@(0.0.255) `&]_[*@3 data], [@(0.0.255) bool]_[*@3 fin]_`=_[@(0.0.255) t
|
||||
rue])&]
|
||||
[s2; Sends the text message. Returns true on success.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:SendBinary`(const void`*`,int64`,bool`):%- [@(0.0.255) bool]_[* SendBin
|
||||
ary]([@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data], [_^int64^ int64]_[*@3 len],
|
||||
[s2;%% Sends the text message. Returns true on success.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:WebSocket`:`:SendBinary`(const void`*`,int64`,bool`): [@(0.0.255) bool]_[* SendBinar
|
||||
y]([@(0.0.255) const]_[@(0.0.255) void]_`*[*@3 data], [_^int64^ int64]_[*@3 len],
|
||||
[@(0.0.255) bool]_[*@3 fin]_`=_[@(0.0.255) true])&]
|
||||
[s5;:WebSocket`:`:SendBinary`(const String`&`,bool`):%- [@(0.0.255) bool]_[* SendBinary](
|
||||
[@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 data], [@(0.0.255) bool]_[*@3 fin]_
|
||||
`=_[@(0.0.255) true])&]
|
||||
[s2; Sends the binary message. Returns true on success.&]
|
||||
[s5;:WebSocket`:`:SendBinary`(const String`&`,bool`): [@(0.0.255) bool]_[* SendBinary]([@(0.0.255) c
|
||||
onst]_[_^String^ String][@(0.0.255) `&]_[*@3 data], [@(0.0.255) bool]_[*@3 fin]_`=_[@(0.0.255) t
|
||||
rue])&]
|
||||
[s2;%% Sends the binary message. Returns true on success.&]
|
||||
[s3;%% &]
|
||||
[s4;%% &]
|
||||
[s5;:WebSocket`:`:Close`(`): [@(0.0.255) void]_[* Close]()&]
|
||||
[s2;%% Closes the websocket.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:IsOpen`(`)const: [@(0.0.255) bool]_[* IsOpen]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns true if WebSocket is associated with open socket.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:Close`(`):%- [@(0.0.255) void]_[* Close]()&]
|
||||
[s2; Closes the websocket.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:WebSocket`:`:IsOpen`(`)const:%- [@(0.0.255) bool]_[* IsOpen]()_[@(0.0.255) const]&]
|
||||
[s2; Returns true if WebSocket is associated with open socket.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:WebSocket`:`:IsError`(`)const:%- [@(0.0.255) bool]_[* IsError]()_[@(0.0.255) const]&]
|
||||
[s2; Returns true if WebSocket is associated with socket and this
|
||||
[s5;:WebSocket`:`:IsError`(`)const: [@(0.0.255) bool]_[* IsError]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns true if WebSocket is associated with socket and this
|
||||
socket returns IsError.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:WebSocket`:`:ClearError`(`):%- [@(0.0.255) void]_[* ClearError]()&]
|
||||
[s2; Clears error in associated socket (if any).&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:WebSocket`:`:GetError`(`)const:%- [@(0.0.255) int]_[* GetError]()_[@(0.0.255) const]&]
|
||||
[s2; Returns error`-code in associated socket, or zero if there is
|
||||
none.&]
|
||||
[s3;%- &]
|
||||
[s4;%- &]
|
||||
[s5;:WebSocket`:`:GetErrorDesc`(`)const:%- [_^String^ String]_[* GetErrorDesc]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s2; Returns error descroption in associated socket, or empty string
|
||||
if there is none.&]
|
||||
[s3;%- &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:MaxLen`(int64`):%- [_^WebSocket^ WebSocket][@(0.0.255) `&]_[* MaxLen]([_^int64^ i
|
||||
nt64]_[*@3 maxlen`_])&]
|
||||
[s2; Sets the maximum length of recieved message to [%-*@3 maxlen]
|
||||
. Default is 10M.&]
|
||||
[s3; &]
|
||||
[s0; ]]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:ClearError`(`): [@(0.0.255) void]_[* ClearError]()&]
|
||||
[s2;%% Clears error in associated socket (if any).&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:GetError`(`)const: [@(0.0.255) int]_[* GetError]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns error`-code in associated socket, or zero if there
|
||||
is none.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:WebSocket`:`:GetErrorDesc`(`)const: [_^String^ String]_[* GetErrorDesc]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s2;%% Returns error descroption in associated socket, or empty string
|
||||
if there is none.&]
|
||||
[s3; &]
|
||||
[s4;%% &]
|
||||
[s5;:WebSocket`:`:MaxLen`(int64`): [_^WebSocket^ WebSocket][@(0.0.255) `&]_[* MaxLen]([_^int64^ i
|
||||
nt64]_[*@3 maxlen`_])&]
|
||||
[s2;%% Sets the maximum length of recieved message to [%-*@3 maxlen]
|
||||
. Default is 10M.&]
|
||||
[s3;%% &]
|
||||
[s0;%% ]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue