After disconnect by timeout can't connect again

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Dukobpa3
Posts: 9
Joined: 26 Jun 2015, 10:15

After disconnect by timeout can't connect again

Postby Dukobpa3 » 11 Nov 2015, 17:31

Code: Select all

5:20:55 PM [SFS>ERROR] [TCPSocketLayer] General error reading data from socket: Read failure   at System.Net.Sockets.NetworkStream.Read (System.Byte[] buffer, Int32 offset, Int32 size) [0x00000] in <filename unknown>:0 at Sfs2X.Core.Sockets.TCPSocketLayer.Read () [0x00000] in <filename unknown>:0


I moves user to login screen after client disconnected by timeout. Then I try to connect again but receive this error. I think it is the response to handshake request.
Should I clean some values in the sfs instance or something else?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: After disconnect by timeout can't connect again

Postby Lapo » 12 Nov 2015, 10:08

Hi,
after you have disconnected you need to recreate the main SmartFox object.

The best approach is to remove all previous listeners in the SFSEvent.CONNECTION_LOST handler, this way you're removing all references to the current object as soon as the client is disconnected, and if the user wants to reconnect again you simply need to recreate the object.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
Dukobpa3
Posts: 9
Joined: 26 Jun 2015, 10:15

Re: After disconnect by timeout can't connect again

Postby Dukobpa3 » 12 Nov 2015, 10:24

recreate the main SmartFox object

Yes I sure it should help.
But I can't mark this solution as the "best approach" :)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: After disconnect by timeout can't connect again

Postby Lapo » 12 Nov 2015, 10:32

I am not sure I understand. That is the exactly the proper way to proceed.
Lapo

--

gotoAndPlay()

...addicted to flash games
Dukobpa3
Posts: 9
Joined: 26 Jun 2015, 10:15

Re: After disconnect by timeout can't connect again

Postby Dukobpa3 » 12 Nov 2015, 10:36

This way seems like "Reset button" on your pc.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: After disconnect by timeout can't connect again

Postby Lapo » 12 Nov 2015, 10:43

No, it simply creates a new session.
And definitely won't reset your PC :D
Lapo

--

gotoAndPlay()

...addicted to flash games
Dukobpa3
Posts: 9
Joined: 26 Jun 2015, 10:15

Re: After disconnect by timeout can't connect again

Postby Dukobpa3 » 12 Nov 2015, 10:45

No, it simply creates a new session.

So some command like "void Connect(newSession = true)" will be much better solution ;)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: After disconnect by timeout can't connect again

Postby Lapo » 12 Nov 2015, 10:53

Why?
Lapo

--

gotoAndPlay()

...addicted to flash games
Dukobpa3
Posts: 9
Joined: 26 Jun 2015, 10:15

Re: After disconnect by timeout can't connect again

Postby Dukobpa3 » 12 Nov 2015, 11:06

The need to re-create the big object - is a symptom of poor cleaning.
And the poor cleaning - is the symptom of memory leaks.
Etc.etc.etc.

Just bad way of coding ;)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: After disconnect by timeout can't connect again

Postby Lapo » 12 Nov 2015, 11:38

You're making a lot of unwarranted assumptions.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 29 guests