Some more progress.

I still need to work on the Streaming, but I've figured out how
to do a bit of introspection which will be necessary when streaming an array.
Started working on the client classes, did ClientObserver and SessionObserver
stuff using flash's event notification system.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3846 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-02-10 03:44:20 +00:00
parent 132dad93d2
commit 85d56cceec
12 changed files with 580 additions and 2 deletions
+69 -2
View File
@@ -1,9 +1,18 @@
package com.threerings.io {
import flash.util.ByteArray;
import com.threerings.util.SimpleMap;
import com.threerings.io.streamers.ArrayStreamer;
import com.threerings.io.streamers.ByteArrayStreamer;
import com.threerings.io.streamers.IntStreamer;
import com.threerings.io.streamers.NumberStreamer;
import com.threerings.io.streamers.StringStreamer;
public class Streamer
{
/*
public static function getStreamer (className :String) :Streamer
//throws IOError
{
@@ -19,6 +28,58 @@ public class Streamer
return streamer;
}
*/
public static function getStreamer (obj :*) :Streamer
{
if (_streamerMap == null) {
createStreamers();
}
if (obj is Streamable) {
return null;
} else if (obj is String) {
return STRING_STREAMER;
} else if (obj is int) {
return INT_STREAMER;
} else if (obj is Number) {
return NUMBER_STREAMER;
} else if (obj is Array) {
return ARRAY_STREAMER;
} else if (obj is ByteArray) {
return BYTE_ARRAY_STREAMER;
} else {
return undefined;
}
}
public static function getStreamerByJavaName (jname :String) :Streamer
{
if (jname === "java.lang.String") {
return STRING_STREAMER;
} else if (jname === "java.lang.Integer") {
return INT_STREAMER;
} else if (jname === "java.lang.Double") {
return NUMBER_STREAMER;
} else if (jname === "[Ljava.lang.Object") {
return ARRAY_STREAMER;
} else if (jname === "[B") {
return BYTE_ARRAY_STREAMER;
} else {
return null;
}
}
/** This should be a protected constructor. */
public function Streamer (targ :Class)
@@ -86,12 +147,18 @@ public class Streamer
protected static function createStreamers () :void
{
_streamerMap = new SimpleMap();
// TODO: fill in with the basic streamers
}
protected var _targ :Class;
protected static var _streamerMap :SimpleMap;
protected static const STRING_STREAMER :Streamer = new StringStreamer();
protected static const BYTE_ARRAY_STREAMER :Streamer =
new ByteArrayStreamer();
protected static const ARRAY_STREAMER :Streamer = new ArrayStreamer();
protected static const INT_STREAMER :Streamer = new IntStreamer();
protected static const NUMBER_STREAMER :Streamer = new NumberStreamer();
}
}