Reading data every lines (ending with CR+LF) from the websocket session
int ws_read_line(int $tcp_id, string &$rbuf)
the number of byte to read
<?php
<?php
include "/lib/sn_tcp_ws.php";
// configuring a websocket and waiting for a connection
ws_setup(0, "my_path", "my_proto");
$rbuf = "";
while(1)
{
if(ws_state(0) == TCP_CONNECTED)
{
ws_read_line(0, $rbuf); // Read one line of data
if(strlen($rbuf) > 0)
{
hexdump($rbuf);
$rbuf = "";
}
sleep(1);
}
}
?>