将websocket session的接收数据按行单位(通过CR+LF区分)读取
int ws_read_line(int $tcp_id, string &$rbuf)
成功时读取的数据(字节数),失败时 0
<?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);
}
}
?>