ReceiveWebSocket (Socket function): Difference between revisions
Line 39: | Line 39: | ||
==Examples== | ==Examples== | ||
The following example receives a text message from a WebSocket client. | |||
<p class="code">... | |||
%sock = WebSocket | |||
if %sock is null then | |||
audittext Socket closed, status is {$STATUSD} | |||
stop | |||
end if | |||
%op = %sock:ReceiveWebSocket(%wsi) | |||
if %op eq 1 then | |||
setText %wso = Received your text message of {%wsi:length} bytes. | |||
%sock:SendWebSocket(%wso, %op, true) | |||
end if | |||
... | |||
</p> | |||
==See also== | ==See also== | ||
{{Template:Socket:ReceiveWebSocket footer}} | {{Template:Socket:ReceiveWebSocket footer}} |
Revision as of 16:24, 19 August 2019
Receive Web Socket framed message (Socket class)
[Introduced in Model 204 7.8 βeta]
This page is under construction.
Syntax
%opCode = socket:ReceiveWebSocket( string)
Syntax terms
%opCode | op code is a number indicating the type of web socket frame received. Numbers 0-7 are non-control frames. Numbers 8-15 are control frames.
| ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
socket | Socket object | ||||||||||||||||||
string | string |
Usage notes
Received data may be masked by the sender. Masked data is always unmasked using the sender's masking key before it is returned to the application.
Examples
The following example receives a text message from a WebSocket client.
... %sock = WebSocket if %sock is null then audittext Socket closed, status is {$STATUSD} stop end if %op = %sock:ReceiveWebSocket(%wsi) if %op eq 1 then setText %wso = Received your text message of {%wsi:length} bytes. %sock:SendWebSocket(%wso, %op, true) end if ...