Hi,
I am reading from a TCP socket but instead of using the prefixed mode I'm relying on my own message structure: I have implemented this as a method in a code module which gets a byte as parameter and adds it to a stringbuilder etc.
Between the calls to this method I need to keep state (am I reading the header info similar as the prefix bytes, or reading the message etc). Currently the state (and other variables) is stored as a variable in the global_process.
However, what if the same code gets executed multiple times (different threads) ? The only solution seems to keep the state variables in the threading code.
In Object-Oriented code I would have created a class that kept the state variables as private variables. Since OO has not yet been implemented in B4A, what would be the best approach ?
I was thing of a map with all variables I need to keep state (a map can also contain a list and other objects ?) so that at least I only need to store 1 variable outside the code module ?
Any other suggestions ?
Thanks
I am reading from a TCP socket but instead of using the prefixed mode I'm relying on my own message structure: I have implemented this as a method in a code module which gets a byte as parameter and adds it to a stringbuilder etc.
Between the calls to this method I need to keep state (am I reading the header info similar as the prefix bytes, or reading the message etc). Currently the state (and other variables) is stored as a variable in the global_process.
However, what if the same code gets executed multiple times (different threads) ? The only solution seems to keep the state variables in the threading code.
In Object-Oriented code I would have created a class that kept the state variables as private variables. Since OO has not yet been implemented in B4A, what would be the best approach ?
I was thing of a map with all variables I need to keep state (a map can also contain a list and other objects ?) so that at least I only need to store 1 variable outside the code module ?
Any other suggestions ?
Thanks