HRC in HTML5 Connection_resume

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

arunesh_mobicules
Posts: 3
Joined: 20 Aug 2013, 14:16

HRC in HTML5 Connection_resume

Postby arunesh_mobicules » 21 Aug 2013, 07:26

Hello,

HRC is not supported by Smartfox.
http://docs2x.smartfoxserver.com/Gettin ... eb-sockets

is there any other option on HRC?

Thanks
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: HRC in HTML5 Connection_resume

Postby Lapo » 21 Aug 2013, 09:23

Basic auto-reconnect can be implemented by listening to the disconnection event and restarting a connection after a few seconds (e.g. 5secs)
Lapo
--
gotoAndPlay()
...addicted to flash games
arunesh_mobicules
Posts: 3
Joined: 20 Aug 2013, 14:16

Re: HRC in HTML5 Connection_resume

Postby arunesh_mobicules » 21 Aug 2013, 09:57

Hi,

Thanks for your reply.

I hope i was not able to clarify my question very well.

Elaborating again. I am planning to make a html5 based poker game. whats the issue coming to me that when a user joins a game ( room ) and starts playing but say after some time the connection gets disconnected. I want to retain the same state where the user was before disconnecting when user joins again.

But the issue what i am facing is that as html 5 does not supports HRC ( resume connection ) feature i am not able to get the current state of the user when he was disconnected.

Please advice how should i implement it.

Thanks,
- Arunesh
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: HRC in HTML5 Connection_resume

Postby rjgtav » 22 Aug 2013, 16:19

Hi there,

You can achieve the same behavior of the HRC system by using a server-side extension.

When the user logs in, you generate an unique random key, attach it to the user and send it back to the client.

When an user is disconnected, you store the reference to the User object on the extension for some limited time.
On the client, when you are disconnected, you either show a "reconnect" button or reconnect automatically.

When you're going to reconnect, you send a new LoginRequest but this time you send the unique random key that you received on the previous session on the extra parameters.
On the extension, where you handle the custom login, you check if there's a valid User object with the provided random key. If there is, then you "transfer" the data from that "old" User object to the new one, such as the UserVariables, joining the same room, etc. At this time you also remove the old User object so that that string can't be re-used.

Hope this helps
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 17 guests