From 2f7399ed6812530921b75c232547b451696c9c32 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Thu, 31 Oct 2002 18:44:34 +0000 Subject: [PATCH] Added support for specifying a version string during the client authentication process. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1870 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/presents/client/Client.java | 23 ++++++++++- .../presents/client/Communicator.java | 5 ++- .../threerings/presents/net/AuthRequest.java | 39 ++++++++++++++----- 3 files changed, 55 insertions(+), 12 deletions(-) diff --git a/src/java/com/threerings/presents/client/Client.java b/src/java/com/threerings/presents/client/Client.java index 67984916c..71d4650ec 100644 --- a/src/java/com/threerings/presents/client/Client.java +++ b/src/java/com/threerings/presents/client/Client.java @@ -1,5 +1,5 @@ // -// $Id: Client.java,v 1.33 2002/10/29 23:51:26 mdb Exp $ +// $Id: Client.java,v 1.34 2002/10/31 18:44:34 mdb Exp $ package com.threerings.presents.client; @@ -155,6 +155,24 @@ public class Client _creds = creds; } + /** + * Returns the version string configured for this client. + */ + public String getVersion () + { + return _version; + } + + /** + * Sets the version string reported to the server during + * authentication. Some server implementations may wish to refuse + * connections by old or invalid client versions. + */ + public void setVersion (String version) + { + _version = version; + } + /** * Returns the distributed object manager associated with this * session. This reference is only valid for the duration of the @@ -545,6 +563,9 @@ public class Client /** The credentials we used to authenticate with the server. */ protected Credentials _creds; + /** The version string reported to the server at auth time. */ + protected String _version = ""; + /** An entity that gives us the ability to process events on the main * client thread (which is also the AWT thread). */ protected Invoker _invoker; diff --git a/src/java/com/threerings/presents/client/Communicator.java b/src/java/com/threerings/presents/client/Communicator.java index a5d028ea2..970973112 100644 --- a/src/java/com/threerings/presents/client/Communicator.java +++ b/src/java/com/threerings/presents/client/Communicator.java @@ -1,5 +1,5 @@ // -// $Id: Communicator.java,v 1.23 2002/10/30 18:46:33 mdb Exp $ +// $Id: Communicator.java,v 1.24 2002/10/31 18:44:34 mdb Exp $ package com.threerings.presents.client; @@ -401,7 +401,8 @@ public class Communicator throws IOException, LogonException { // construct an auth request and send it - AuthRequest req = new AuthRequest(_client.getCredentials()); + AuthRequest req = new AuthRequest(_client.getCredentials(), + _client.getVersion()); sendMessage(req); // now wait for the auth response diff --git a/src/java/com/threerings/presents/net/AuthRequest.java b/src/java/com/threerings/presents/net/AuthRequest.java index 78daffe4c..dd0710cc5 100644 --- a/src/java/com/threerings/presents/net/AuthRequest.java +++ b/src/java/com/threerings/presents/net/AuthRequest.java @@ -1,5 +1,5 @@ // -// $Id: AuthRequest.java,v 1.8 2002/07/23 05:52:48 mdb Exp $ +// $Id: AuthRequest.java,v 1.9 2002/10/31 18:44:34 mdb Exp $ package com.threerings.presents.net; @@ -19,18 +19,32 @@ public class AuthRequest extends UpstreamMessage } /** - * Constructs a auth request with the supplied credentials. + * Constructs a auth request with the supplied credentials and client + * version information. */ - public AuthRequest (Credentials creds) + public AuthRequest (Credentials creds, String version) { _creds = creds; + _version = version; } + /** + * Returns a reference to the credentials provided with this request. + */ public Credentials getCredentials () { return _creds; } + /** + * Returns a reference to the version information provided with this + * request. + */ + public String getVersion () + { + return _version; + } + /** * Writes our custom streamable fields. */ @@ -39,6 +53,7 @@ public class AuthRequest extends UpstreamMessage { super.writeObject(out); out.writeObject(_creds); + out.writeUTF(_version); } /** @@ -49,15 +64,21 @@ public class AuthRequest extends UpstreamMessage { super.readObject(in); _creds = (Credentials)in.readObject(); - } - - public String toString () - { - return "[type=AREQ, msgid=" + messageId + ", creds=" + _creds + "]"; + _version = in.readUTF(); } /** - * The credentials associated with this auth request. + * Generates a string representation of this instance. */ + public String toString () + { + return "[type=AREQ, msgid=" + messageId + ", creds=" + _creds + + ", version=" + _version + "]"; + } + + /** The credentials associated with this auth request. */ protected Credentials _creds; + + /** The version information associated with the client code. */ + protected String _version; }