I try to understand details on WebSockets in B4j by learning from examples provided by Erel. I have a question on the ChatExample that consists out of a ChatShared code module and two classes holding a WebSocket reference and using the code module (ChatLogin and Chat class).
My question is:
In the ChatLogin class the code module is accessed directly, i.e. in line 28:
But in the Chat class the code module is accessed by CallSubDelayed, i.e. in line 22:
What was the motivation to use different ways? Where are advantages of the one or the other way?
(Especially the Chat class surprised me, because long ago I learned that static code modules cannot handle events.)
Thank you very much,
Thomas
My question is:
In the ChatLogin class the code module is accessed directly, i.e. in line 28:
ChatLogin class line 28:
ChatShared.AvoidDuplicates.Put(name.ToLowerCase, name)
But in the Chat class the code module is accessed by CallSubDelayed, i.e. in line 22:
Chat class line 22:
CallSubDelayed3(ChatShared, "NewConnection", Me, name)
What was the motivation to use different ways? Where are advantages of the one or the other way?
(Especially the Chat class surprised me, because long ago I learned that static code modules cannot handle events.)
Thank you very much,
Thomas