Disallow older clients from connecting to the server.

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

rahul.huels450
Posts: 4
Joined: 12 Jun 2021, 17:42

Disallow older clients from connecting to the server.

Postby rahul.huels450 » 12 Jun 2021, 17:45

Hi there, I'd like to know how you'd disallow users from connecting if they're on an older version of the client.

Let's say there is a string variable called "version" = 1.0, but a new update is out for version 1.1.

How would I make it so users who connect to my smartfoxserver be kicked for needing to update? :?:

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

Re: Disallow older clients from connecting to the server.

Postby Lapo » 13 Jun 2021, 10:57

Hi,
you can send custom data with the Login request object so you could send the client version and verify it on the server side, only allowing in players with the correct version.

Here's an example of server side login:
https://smartfoxserver.com/blog/how-to- ... tom-login/

The client side LoginRequest constructor looks like this (Java):

Code: Select all

public LoginRequest(String userName, String password, String zoneName, ISFSObject params)

Where the last params is the custom data object you can use.

It works the same in all other client side API as well.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
rahul.huels450
Posts: 4
Joined: 12 Jun 2021, 17:42

Re: Disallow older clients from connecting to the server.

Postby rahul.huels450 » 13 Jun 2021, 21:01

Is it possible to do this with SFSEvent.onLogin or SFSEvent.onConnection?
User avatar
Lapo
Site Admin
Posts: 22064
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Disallow older clients from connecting to the server.

Postby Lapo » 14 Jun 2021, 07:36

Sorry,
I just noticed you posted under the SFS PRO 1.x section... so you're not referring to SFS2X, right?
Lapo

--

gotoAndPlay()

...addicted to flash games
rahul.huels450
Posts: 4
Joined: 12 Jun 2021, 17:42

Re: Disallow older clients from connecting to the server.

Postby rahul.huels450 » 14 Jun 2021, 23:45

Correct. I am using SmartFoxServer Pro 1.x! :)
User avatar
Lapo
Site Admin
Posts: 22064
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Disallow older clients from connecting to the server.

Postby Lapo » 15 Jun 2021, 06:40

Ok sorry, my bad :)
In any case the process should be the same, with a slight variation.

In SFS1.x you will need to login first, then from client side send an Extension call with the client version. Server side you can validate it and disconnect the user if you decide it's not valid.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
rahul.huels450
Posts: 4
Joined: 12 Jun 2021, 17:42

Re: Disallow older clients from connecting to the server.

Postby rahul.huels450 » 20 Jun 2021, 02:16

Okay, I threw something together that almost works perfectly. But, since clients are using an older version that doesn't send any version info to the server. How would I via the server-side extension. (I am using an actionscript extension) tell it that if there is no information from the client, then disconnect the user?

It currently will remove the user if the version is not the same but if it doesn't send any message to the server at all they can still connect fine since the server never received the message. Any examples? I couldn't find anything like this. But maybe I did something a little unintuitive. Let me know! :?
User avatar
Lapo
Site Admin
Posts: 22064
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Disallow older clients from connecting to the server.

Postby Lapo » 23 Jun 2021, 17:33

Sorry for the delay, I see what you mean.
I don't think there's a robust solution for this, at least not in SFS1.x, since it doesn't support additional data to be sent at login time.

You could still verify if the client has already sent a version number, when an Extension request is received. If no value exists for such User you could do something about it. It's not ideal, but it might work.

In SFS2X this would be pretty easy to do, since the version could be sent at login time and stored as User property.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 31 guests