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

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

Moderators: Lapo, Bax

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

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

Postby crimsonfantasy » 30 May 2018, 05:21

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: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 30 May 2018, 08:07

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..

Postby crimsonfantasy » 31 May 2018, 02:02

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: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

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

Postby Lapo » 31 May 2018, 07:27

Yes, this applies to all supported API.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 6 guests