x.websocket: workaround `for _, item in a_map{}` bug, causing panic (#8463)

pull/8474/head
Tomas Hellström 2021-01-31 10:37:32 +01:00 committed by GitHub
parent 5746ac4dd4
commit 7eb7d042ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -26,8 +26,9 @@ fn start_server() ? {
// on_message_ref, broadcast all incoming messages to all clients except the one sent it // on_message_ref, broadcast all incoming messages to all clients except the one sent it
s.on_message_ref(fn (mut ws websocket.Client, msg &websocket.Message, mut m websocket.Server) ? { s.on_message_ref(fn (mut ws websocket.Client, msg &websocket.Message, mut m websocket.Server) ? {
for _, cli in m.clients { // for _, cli in m.clients {
mut c := cli for i, _ in m.clients {
mut c := m.clients[i]
if c.client.state == .open && c.client.id != ws.id { if c.client.state == .open && c.client.id != ws.id {
c.client.write(msg.payload, websocket.OPCode.text_frame) or { c.client.write(msg.payload, websocket.OPCode.text_frame) or {
panic(err) panic(err)