2

我正在使用 PHP websockets。我熟悉它的基础知识,但我不知道如何为用户设置特定的 ID。现在,默认情况下,脚本根据用户连接的时间设置 1、2、3 等,但我希望它设置存储在会话中的 ID。我使用的脚本是这个。我找到了生成 ID 的函数。

function wsGetNextClientID() {
    $i = 1; // starts at 1 because 0 is the listen socket
    while (isset($this->wsRead[$i])) $i++;
    return $i;
}

有什么办法可以设置一个特定的吗?

4

0 回答 0