Game Development Community

How do I kick a client during startup?

by Igor G · in Torque Game Engine · 10/15/2007 (8:38 am) · 4 replies

I want the client to send a game version as part of the connection args.
If the client's version doesn't match the server's version, I want to kick the client.

So, I will need to check the connection arg in function GameConnection::onConnect, and somehow remove the connection. However, if I do %client.delete, this will crash the executable. Is there a way for me to do this??

Thanks.

#1
10/15/2007 (9:09 am)
There is an explicit kick command, look it up. Sorry I can't be more help, don't have a copy of porque in front of me.
#2
10/15/2007 (10:42 am)
Yes, I do realize there is a kick command - but that requires deleting the connection. However, my problem is that I want to add this check inside the onConnect, which is a member of GameConnection. Calling delete on the client object causes it to crash. Is there another way to disconnect the client and give them a reason for disconnecting?
#3
11/03/2007 (10:26 pm)
I'm not entirely sure but I think you might be able to just do return "You have an outdated Version"; in the onConnect code, similar to the rejection for server full etc. but i'm not entirely sure.

Alternatively you can just schedule the connection delete for 100ms or something.
#4
11/04/2007 (7:10 am)
Igor, by default Torque kicks the connection if in function onConnectRequest() you return non-empty value, e.g.:
function GameConnection::onConnectRequest( %client, %netAddress, %name, %pass, %ver)
{
   if (%ver !$= $Server::CurrentVersion)
   {
      return "BC_BADVER";
   }
   // here your code to check the login/password combination
}
on client-side you check the disconnect reason:
function GameConnection::onConnectRequestRejected( %this, %msg )
{
   switch$(%msg)
   {
      case "BC_BADVER":
         %error = "Your client version is not match the server." NL
            "Please be sure you have downloaded latest client with all updates applied.";
      //... all the rest cases here
   }
   MessageBoxOK( "Connection rejected", %error);
}

This is how I do in my AfterWorld project.