From 53aacc4bbc80d4ddb60df52836377e098c53cbcd Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Sat, 12 Aug 2006 01:19:30 +0000 Subject: [PATCH] Added ClassUtil.isSameClass(), reimplemented another function using the constructor property. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4322 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/presents/client/Communicator.as | 12 ++++++++++-- src/as/com/threerings/util/ClassUtil.as | 7 ++++++- src/as/com/threerings/util/Name.as | 4 +--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/as/com/threerings/presents/client/Communicator.as b/src/as/com/threerings/presents/client/Communicator.as index b6c9878ba..b27f0b137 100644 --- a/src/as/com/threerings/presents/client/Communicator.as +++ b/src/as/com/threerings/presents/client/Communicator.as @@ -201,8 +201,16 @@ public class Communicator //Log.debug("length of in frame: " + frameData.length); //Log.debug("inBuffer: " + Util.bytesToString(frameData)); _inStream.setSource(frameData); - var msg :DownstreamMessage = - (_inStream.readObject() as DownstreamMessage); + var msg :DownstreamMessage; + try { + msg = (_inStream.readObject() as DownstreamMessage); + } catch (e :Error) { + var log :Log = Log.getLog(this); + log.warning("Error processing downstream message: " + e); + log.logStackTrace(e); + return; + } + if (frameData.bytesAvailable > 0) { Log.getLog(this).warning( "Beans! We didn't fully read a frame, surely there's " + diff --git a/src/as/com/threerings/util/ClassUtil.as b/src/as/com/threerings/util/ClassUtil.as index 43b903588..795e82c83 100644 --- a/src/as/com/threerings/util/ClassUtil.as +++ b/src/as/com/threerings/util/ClassUtil.as @@ -31,9 +31,14 @@ public class ClassUtil return new clazz(); } + public static function isSameClass (obj1 :Object, obj2 :Object) :Boolean + { + return (obj1.constructor == obj2.constructor); + } + public static function getClass (obj :Object) :Class { - return getClassByName(getClassName(obj)); + return Class(obj.constructor); } public static function getClassByName (cname :String) :Class diff --git a/src/as/com/threerings/util/Name.as b/src/as/com/threerings/util/Name.as index d3e7807c3..310ad9c71 100644 --- a/src/as/com/threerings/util/Name.as +++ b/src/as/com/threerings/util/Name.as @@ -43,9 +43,7 @@ public class Name extends Object // from interface Hashable public function equals (other :Object) :Boolean { - return (other != null) && - // this is a check to see if they are the same class - (other.constructor == Object(this).constructor) && + return (other != null) && ClassUtil.isSameClass(other, this) && (getNormal() === (other as Name).getNormal()); }