Hi all, I'm facing with the problem. I have a simple TCP server (C#). And i create new tcp socket at client, but when i get a new message (the message is a string) from server, i cannot update UI. Please help me
WhiteTree Games - Home, home on the web, where the bits and bytes they do play! #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Firstly, when you create a client, set it's timeout to 0, so it won't block UI
client:settimeout(0)
Secondly, listen in timer and not in loop, since times are like async calls (they are not async, but they act like ones), listening about 10 times a second should be enough.
--running timer 10 times each second should be sufficientlocal timer = Timer.new(100)
timer:addEventListener(Event.TIMER, function()--do what you need to do hereend)--start the timer
timer:start()
If that didn't answer your question, try elaborate on it
Comments
What do you mean "I cannot update UI" ?
Likes: phuochau
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
What I'm expecting is when client receives a string from server, client will set text for text field
Firstly, when you create a client, set it's timeout to 0, so it won't block UI
Likes: phuochau
Thanks, I will try it now
Working , thanks for your support. Code complete such as below. I use 2 timers to do that.
Likes: phuochau