B4J Question Delay in execution WebSocket_ disconnected with b4j

mohammad be

Member
Hello everyone
I am using a web socket
The event occurs when the customer is disconnected
Runs with a delay of about a few minutes. what's the reason?????
B4X:
Private Sub WebSocket_Disconnected
    Log("del ws : "&ws.Session.Id)
    For i=Main.Users.Size-1 To 0 Step -1
        Dim tmp As j=Main.Users.Get(i)
'        Log("p_0 : "&tmp.Data.Session.Id.Trim)
'        Log("p_1 : "&ws.Session.Id.Trim)
        If tmp.Data.Session.Id.Trim=ws.Session.Id.Trim Then
            SetChatOnOff(tmp.Code,False)
            Sleep(0)
            Log("Delete From list "&ws.Session.Id)
            Log("p_ID : "&tmp.Code)
            CallSub3(Main,"SendMessage3",tmp.Code,"")
            Main.Users.RemoveAt(i)
        End If
    Next
    Log("-----------")
    Log("Total Users : "&Main.Users.Size)
    Log("-----------")
End Sub
 
Top