Page 1 of 1
Disallow older clients from connecting to the server.
Posted: 12 Jun 2021, 17:45
by rahul.huels450
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!
Re: Disallow older clients from connecting to the server.
Posted: 13 Jun 2021, 10:57
by Lapo
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
Re: Disallow older clients from connecting to the server.
Posted: 13 Jun 2021, 21:01
by rahul.huels450
Is it possible to do this with SFSEvent.onLogin or SFSEvent.onConnection?
Re: Disallow older clients from connecting to the server.
Posted: 14 Jun 2021, 07:36
by Lapo
Sorry,
I just noticed you posted under the SFS PRO 1.x section... so you're not referring to SFS2X, right?
Re: Disallow older clients from connecting to the server.
Posted: 14 Jun 2021, 23:45
by rahul.huels450
Correct. I am using SmartFoxServer Pro 1.x!

Re: Disallow older clients from connecting to the server.
Posted: 15 Jun 2021, 06:40
by Lapo
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
Re: Disallow older clients from connecting to the server.
Posted: 20 Jun 2021, 02:16
by rahul.huels450
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!

Re: Disallow older clients from connecting to the server.
Posted: 23 Jun 2021, 17:33
by Lapo
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