Note that the CallSubDelayed calls are important. Without them the code will be executed on the connection specific thread.
Yes but... is there a thread where the room code is executed? Of course it exists, but which is it?
Each instance of the websocket handler class (which I consider as a user, a client) has a reference to the room it "belongs to", so the code looks like:
' websocket handler class
Private Room As clsRoom
Room = [one of the room in the Main.mapRooms]
CallSubDelayed2(Room, "RoutineName", "Data")
An user (websocket handler class) creates (declares and initializes) a new room, when needed, and add it to the Main.mapRooms.
Other clients will have a reference to that room, using the code above. In which thread will the room code run when called using CallSubDelayed from the clients that have a reference to that room?
The answer could be: "run a test". The point is that so far, since I had forgotten the difference between Debug and Release in this regard, I always started the server in Debug mode; when, by mistake, I did it in Release, I got very unpleasant results - even (or mainly?) a "Wait For", with the threads, ...! and then I remembered the difference between the two modes
.
All very hard to explain using words only