When clinet connecting again, there is a new ThreadPool..

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

Post Reply
crimsonfantasy
Posts: 13
Joined: 21 Feb 2018, 03:02

When clinet connecting again, there is a new ThreadPool..

Post by crimsonfantasy »

We detect client whether it is lose connection. If client lose connection, we use Sfsclient.connect again.
If connection is still not be establish, the job keep using Sfsclient.connect again.
We discover a Thread Pool created after using Sfsclient.connect.
So the worst situation is client program will be out of memory because there are so many Thread Pool that created by SfsClient in JVM.
Cloud you inspire me what is the explicit way to implement sfsclient reconnecting? No redundant thread pool existing .
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: When clinet connecting again, there is a new ThreadPool..

Post by Lapo »

Hi,
when a client is disconnected you need to create a new SmartFox object so that the old one gets garbage collected.

To do this correctly you listen to the SFSEvent.CONNECTION_LOST and in the handler you remove all listeners before proceeding to create a new SmartFox instance.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
crimsonfantasy
Posts: 13
Joined: 21 Feb 2018, 03:02

Re: When clinet connecting again, there is a new ThreadPool..

Post by crimsonfantasy »

Sorry, I known this is Java client forum here.
So does same methodology as Java to handle reconnecting when using JavaScript as client?
Thank you
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: When clinet connecting again, there is a new ThreadPool..

Post by Lapo »

Yes, this applies to all supported API.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply