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:
@@ -0,0 +1,41 @@
|
||||
package com.threerings.io.streamers {
|
||||
|
||||
import flash.util.ByteArray;
|
||||
|
||||
import com.threerings.io.ObjectInputStream;
|
||||
import com.threerings.io.ObjectOutputStream;
|
||||
import com.threerings.io.Streamer;
|
||||
|
||||
/**
|
||||
* A Streamer for ByteArray objects.
|
||||
*/
|
||||
public class ByteArrayStreamer extends Streamer
|
||||
{
|
||||
public function ByteArrayStreamer ()
|
||||
{
|
||||
super(ByteArray);
|
||||
}
|
||||
|
||||
public override function createObject (ins :ObjectInputStream) :*
|
||||
{
|
||||
var bytes :ByteArray = new ByteArray();
|
||||
bytes.length = ins.readInt();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public override function writeObject (obj :*, out :ObjectOutputStream,
|
||||
useWriter :Boolean) :void
|
||||
{
|
||||
var bytes :ByteArray = (obj as ByteArray);
|
||||
out.writeInt(bytes.length);
|
||||
out.writeBytes(bytes);
|
||||
}
|
||||
|
||||
public override function readObject (obj :*, ins :ObjectInputStream,
|
||||
useReader :Boolean) :void
|
||||
{
|
||||
var bytes :ByteArray = (obj as ByteArray);
|
||||
ins.readBytes(bytes, 0, bytes.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user