(I don't think I have to create a new thread for this, it seems to be related to the same thing)
Trying to get the values added to a "thread safe map":
MAIN
B4X:
Sub Process_Globals
Public srvr As Server
Public mapGameRooms As Map
End Sub
B4X:
Sub AppStart (Args() As String)
...
mapGameRooms = srvr.CreateThreadSafeMap
For r = 0 To 4
Dim GameRoom As clsGameRoom
GameRoom.Initialize
Dim GameRoomName As String = "Room " & r
GameRoom.Name = GameRoomName
mapGameRooms.Put(GameRoomName, GameRoom)
Next
StartMessageLoop
End Sub
Websocket class
B4X:
Private Sub RunOnClient_SendRoomsList(Msg As String)
Dim lst As List
lst.Initialize
Dim GameRoom As clsGameRoom
For r = 0 To Main.mapGameRooms.Size - 1
GameRoom = Main.mapGameRooms.Get(r)
If GameRoom <> Null Then
lst.Add(GameRoom.Name)
Else
Log("GameRoom is null")
End If
Next
ws.RunFunction("FromServer_Rooms", lst)
ws.Flush
End Sub
The comments for Server.CreateThreadSafeMap make it clear that the Map created by this function doesn't support Map.GetValueAt and Map.GetKeyAt nor does it preserve the order of the elements.
The comments for Server.CreateThreadSafeMap make it clear that the Map created by this function doesn't support Map.GetValueAt and Map.GetKeyAt nor does it preserve the order of the elements.
The comments for Server.CreateThreadSafeMap make it clear that the Map created by this function doesn't support Map.GetValueAt and Map.GetKeyAt nor does it preserve the order of the elements.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.