Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event 案例中的event_arr不太明白 请教下 #52

Open
bimoQi opened this issue Oct 21, 2019 · 1 comment
Open

event 案例中的event_arr不太明白 请教下 #52

bimoQi opened this issue Oct 21, 2019 · 1 comment

Comments

@bimoQi
Copy link

bimoQi commented Oct 21, 2019

在 案例 14. PHP [socket初探中](https://github.com/elarity/advanced-php/blob/master/14.%20PHP%20socket%E5%88%9D%E6%8E%A2%20---%20%E5%90%AB%E7%9D%80%E6%B3%AA%E4%B9%9F%E8%A6%81%E7%A3%95%E5%AE%8Clibevent%EF%BC%88%E4%B8%89%EF%BC%89.md)
聊天代码里
// 这里值得注意,我们声明两个数组用来保存 事件 和 连接socket $event_arr = []; $conn_arr = []; // 此处值得注意,我们需要将事件本身存储到全局数组中,如果不保存,连接会话会丢失,也就是说服务端和客户端将无法保持持久会话 $event_arr[ intval( $conn ) ] = $event;
这里的event_arr 感觉完全没有应到到其他地方 只是将event保存了到数组并没有对数组进行操作

@elarity
Copy link
Owner

elarity commented Feb 2, 2022

其实你试一下,如果不保存会这样,就知道了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants