Commit 52e182cc authored by Carsten  Rose's avatar Carsten Rose

Refs #11076. Decode answer respecting websocket definition. Start add documentation.

parent 28b461fe
Pipeline #3745 canceled with stages
......@@ -714,7 +714,9 @@ Column: _link
|x | |Copy to |y:[some content] |y:this will be copied |Click on it copies the value of 'y:' to the clipboard. Optional a file ('F:...') might be specified as source. |
| | |clipboard | | |See :ref:`copyToClipboard`. |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Dropdown menu |z |z||p:home|t:Home |Creates a dropdown menu. SEe :ref:`dropdownMenu`. |
| | |Dropdown menu |z |z||p:home|t:Home |Creates a dropdown menu. See :ref:`dropdownMenu`. |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |websocket |w:ws://<host>:<port>/<path> | w:ws://localhost:123/demo |Send message given in 't:...' to websocket. See :ref:`websocket`. |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
| | |Text |t:<text> |t:Firstname Lastname | |
+---+---+--------------+-----------------------------------+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
......@@ -2183,6 +2185,36 @@ Line 6: A PDF download.
Line 7: A disabled menu entry.
.. _websocket:
WebSocket
---------
Sending messages via WebSocket and receiving the answer is done via: ::
SELECT 'w:ws://<host>:<port>/<path>|t:<message>' AS _websocket
Instead of '... AS _websocket' it's also possible to use '... AS _link'.
<dropdown menu symbol options>||<menu entry 1>||<menu entry 2>||...
10.sql = SELECT CONCAT('w:ws://example.com:8000/demo|t:{"action":"echo","data":"hello world',f.id,'"}') AS '_websocket'
                , CONCAT('w:ws://webwork16.math.uzh.ch:8000/demo|t:{"action":"echo","data":"good morning',f.id,'"}') AS '_websocket|col2|_hide'
                , CONCAT('w:ws://webwork16.math.uzh.ch:8000/demo|t:{"action":"echo","data":"good evening',f.id,'"}') AS '_websocket|col3|_hide'
           FROM Form AS f
           ORDER BY f.id
           LIMIT 3
                                                                                                     
#20.sql = SELECT 'w:ws://webwork16.math.uzh.ch:8000/demo|t:{"action":"ping","data":"my ping"}' AS '_websocket|col1', 'Datetime: ', NOW()
  
10.20.sql = SELECT "<br><br>-{{&col1:R}} / {{&col2:R}} / {{&col3:R}}="  
.. _drag_and_drop:
Drag and drop
......
......@@ -85,9 +85,10 @@ class WebSocket {
$answer .= $buffer;
}
// It seems we have two control characters at the beginning: don't understand why.
if (ord($answer[0]) == 129) {
$answer = substr($answer, 2);
// Decode WebSocket answer
if ($answer !== '') {
$data = $this->hybi10Decode($answer);
$answer = $data['payload'];
}
return $answer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment