From 334bf083314148c7cfe380cdfcb32102e8628064 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 22 Feb 2006 04:31:25 +0000 Subject: [PATCH] Need to use UsernamePasswordCreds to log in (Credentials is abstract in Java, but there's no such thing in actionscript). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3877 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/presents/client/TestClient.as | 4 ++-- .../threerings/presents/net/AuthRequest.as | 1 + .../threerings/presents/net/Credentials.as | 20 ++++++++++++++++++- .../presents/net/UsernamePasswordCreds.as | 10 ++++++---- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/as/com/threerings/presents/client/TestClient.as b/src/as/com/threerings/presents/client/TestClient.as index 949c6fb71..4e8dc8eeb 100644 --- a/src/as/com/threerings/presents/client/TestClient.as +++ b/src/as/com/threerings/presents/client/TestClient.as @@ -1,13 +1,13 @@ package com.threerings.presents.client { import com.threerings.util.Name; -import com.threerings.presents.net.Credentials; +import com.threerings.presents.net.UsernamePasswordCreds; public class TestClient extends Client { public function TestClient () { - super(new Credentials(new Name("Ray"))); + super(new UsernamePasswordCreds(new Name("Ray"), "fork-u-2")); setServer("tasman.sea.earth.threerings.net", DEFAULT_SERVER_PORT); logon(); } diff --git a/src/as/com/threerings/presents/net/AuthRequest.as b/src/as/com/threerings/presents/net/AuthRequest.as index 8197dd231..e8e4cdf6f 100644 --- a/src/as/com/threerings/presents/net/AuthRequest.as +++ b/src/as/com/threerings/presents/net/AuthRequest.as @@ -24,6 +24,7 @@ public class AuthRequest extends UpstreamMessage public override function readObject (ins :ObjectInputStream) :void { super.readObject(ins); + _creds = (ins.readObject() as Credentials); _version = (ins.readField(String) as String); } diff --git a/src/as/com/threerings/presents/net/Credentials.as b/src/as/com/threerings/presents/net/Credentials.as index fb87167bf..d3a5c462c 100644 --- a/src/as/com/threerings/presents/net/Credentials.as +++ b/src/as/com/threerings/presents/net/Credentials.as @@ -1,8 +1,13 @@ package com.threerings.presents.net { -import com.threerings.io.*; +import flash.util.StringBuilder; + import com.threerings.util.Name; +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; +import com.threerings.io.Streamable; + public class Credentials implements Streamable { @@ -25,6 +30,19 @@ public class Credentials _username = (ins.readObject() as Name); } + public function toString () :String + { + var buf :StringBuilder = new StringBuilder("["); + toStringBuf(buf); + buf.append("]"); + return buf.toString(); + } + + internal function toStringBuf (buf :StringBuilder) :void + { + buf.append("username=", _username); + } + /** The username. */ protected var _username :Name; } diff --git a/src/as/com/threerings/presents/net/UsernamePasswordCreds.as b/src/as/com/threerings/presents/net/UsernamePasswordCreds.as index b388c5b9a..e1a1b6768 100644 --- a/src/as/com/threerings/presents/net/UsernamePasswordCreds.as +++ b/src/as/com/threerings/presents/net/UsernamePasswordCreds.as @@ -21,10 +21,12 @@ package com.threerings.presents.net { +import flash.util.StringBuilder; + import com.threerings.util.Name; -import com.threerrings.io.ObjectInputStream; -import com.threerrings.io.ObjectOutputStream; +import com.threerings.io.ObjectInputStream; +import com.threerings.io.ObjectOutputStream; public class UsernamePasswordCreds extends Credentials { @@ -51,11 +53,11 @@ public class UsernamePasswordCreds extends Credentials public override function readObject (ins :ObjectInputStream) :void { super.readObject(ins); - _password = ins.readField(String); + _password = (ins.readField(String) as String); } // documentation inherited - protected override function toStringBuf (buf :StringBuilder) + internal override function toStringBuf (buf :StringBuilder) :void { super.toStringBuf(buf); buf.append(", password=", _password);