You are not logged in.
Pages: 1
Hi,
I have created a LAMW android chat client for testing the websocket connection with the Project31 chat server. The websocket part is working well , but I could not find any info on how to synchronize my code in NotifyBlaBla with the main thread in a GUI (none console) client.
Last edited by Leslie7 (2017-12-25 22:22:57)
Offline
ab,
wow, you are present on the forum even today ...
LAMW is for Lazarus. It creates a CustomApplication which uses native controls via JNI to build the GUI. The pascal code is compiled into ".so", so anything that works for linux may be working here as well.
I can see a few possible general solutions:
1. Creating a thread for the sole purpose of passing the callback messages to the main thread. (eg a synchronized calling of a function of the form) .
2. Creating the websocket client in the context of a thread instead of the main thread. - Is this a good idea for bidir communication?
3. Msg for the main window proc - not sure, this is a real option with LAMW
Last edited by Leslie7 (2017-12-26 09:32:04)
Offline
If you are able to share your code somewhere, I can have a look also.
Offline
AOG
I am trying out a few things. I will definitely ask for your help if I cannot get it working.
Thanks
Offline
There is a simple workaround but it is not optimal:
1. we need a thread safe temporary storage
2. where the messages are stored by the callback method
3. a jTimer instance periodically checks if there are new stored messages and clears the temporary storage after the messages are displayed
Since LAMW does not have message handling on the pascal side probably the only way to do this properly is to go to the Java side first via JNI and call back to the pascal side in a synchronized fashion.
Offline
Pages: 1