| Package | com.whirled.contrib |
| Class | public class Chunker |
| Inheritance | Chunker flash.events.EventDispatcher |
| Property | Defined by | ||
|---|---|---|---|
| _ctrl : EntityControl The entity control we're using.
| Chunker | ||
| _inChunks : Object Holds incomplete chunks being received.
| Chunker | ||
| _msgName : String The message name we're using.
| Chunker | ||
| _nextSend : int The time at which we should send the next chunk.
| Chunker | ||
| _outData : ByteArray The data we're currently sending.
| Chunker | ||
| _outTokens : int Some tokens describing the format of the _outData.
| Chunker | ||
| _thisId : String The instance id of this instance of the chunker.
| Chunker | ||
| _timer : Timer The Timer used to throttle sends.
| Chunker | ||
| Method | Defined by | ||
|---|---|---|---|
|
Chunker(ctrl:EntityControl, msgName:String = "chunk", receivedCallback:Function = null)
Construct a Chunker.
| Chunker | ||
|
send(data:Object, compressStrategy:int):void
Send this data to all instances of this entity in chunked and throttled messages.
| Chunker | ||
| Method | Defined by | ||
|---|---|---|---|
|
checkSendChunk():void
Check to see if enough time has passed to send the next chunk.
| Chunker | ||
|
chunkReceived(id:String, inBytes:ByteArray):void
Handle a received chunk.
| Chunker | ||
|
countChunks(dataLength:int):int
[static]
Counts the number of chunks to send data of the specified length.
| Chunker | ||
|
handleMessage(event:ControlEvent):void
Handles ControlEvent.MESSAGE_RECEIVED.
| Chunker | ||
|
handleUnload(event:Event):void
Handles Event.UNLOAD.
| Chunker | ||
|
sendChunk(... ignored):void
Send the next chunk.
| Chunker | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when the chunks are reconstituted and ready to use. | Chunker | |||
| Constant | Defined by | ||
|---|---|---|---|
| ALWAYS_COMPRESS : int = 0 [static] A compression strategy that always compresses the data, regardless of whether it
saved any space.
| Chunker | ||
| NEVER_COMPRESS : int = 2 [static] A compression strategy that says: don't ever even waste time trying to compress.
| Chunker | ||
| TRY_COMPRESS : int = 1 [static] A compression stragegy that tries to compress the data, but only sends the compressed
form if it would actually result in sending less chunks.
| Chunker | ||
| Constant | Defined by | ||
|---|---|---|---|
| COMPRESSED_TOKEN : int [static]
| Chunker | ||
| END_TOKEN : int [static]
| Chunker | ||
| MAX_CHUNK_DATA : int = 1020 [static] The maximum size of our chunks.
| Chunker | ||
| MIN_SEND_WAIT : int = 200 [static] The minimum time between sends.
| Chunker | ||
| NO_TOKENS : int = 0 [static] Token constants.
| Chunker | ||
| OBJECT_TOKEN : int [static]
| Chunker | ||
| START_TOKEN : int [static]
| Chunker | ||
| _ctrl | property |
protected var _ctrl:EntityControlThe entity control we're using.
| _inChunks | property |
protected var _inChunks:ObjectHolds incomplete chunks being received.
| _msgName | property |
protected var _msgName:StringThe message name we're using.
| _nextSend | property |
protected var _nextSend:intThe time at which we should send the next chunk.
| _outData | property |
protected var _outData:ByteArrayThe data we're currently sending.
| _outTokens | property |
protected var _outTokens:intSome tokens describing the format of the _outData.
| _thisId | property |
protected var _thisId:StringThe instance id of this instance of the chunker.
| _timer | property |
protected var _timer:TimerThe Timer used to throttle sends. Only used on the sender.
| Chunker | () | constructor |
public function Chunker(ctrl:EntityControl, msgName:String = "chunk", receivedCallback:Function = null)Construct a Chunker.
Parametersctrl:EntityControl — your AvatarControl or ToyControl, etc.
|
|
msgName:String (default = "chunk") — the prefix name of the message to use for data sent using this chunker.
|
|
receivedCallback:Function (default = null) — may be specified instead of listening for the complete event,
this function will be invoked when the data is received. Only the value is returned.
Signature: function (data :Object) :void;
|
| checkSendChunk | () | method |
protected function checkSendChunk():voidCheck to see if enough time has passed to send the next chunk.
| chunkReceived | () | method |
protected function chunkReceived(id:String, inBytes:ByteArray):voidHandle a received chunk.
Parametersid:String |
|
inBytes:ByteArray |
| countChunks | () | method |
protected static function countChunks(dataLength:int):intCounts the number of chunks to send data of the specified length.
ParametersdataLength:int |
int |
| handleMessage | () | method |
protected function handleMessage(event:ControlEvent):voidHandles ControlEvent.MESSAGE_RECEIVED.
Parametersevent:ControlEvent |
| handleUnload | () | method |
protected function handleUnload(event:Event):voidHandles Event.UNLOAD.
Parametersevent:Event |
| send | () | method |
public function send(data:Object, compressStrategy:int):voidSend this data to all instances of this entity in chunked and throttled messages.
Parametersdata:Object — a ByteArray or any other object graph that can be serialized to AMF3.
|
|
compressStrategy:int — the strategy to take when deciding whether to compress the data.
|
| sendChunk | () | method |
protected function sendChunk(... ignored):voidSend the next chunk.
Parameters... ignored |
| complete | event |
com.threerings.util.NamedValueEvent
Dispatched when the chunks are reconstituted and ready to use. The 'name' property will contain the String version of the instance id that sent the data. The 'value' property will contain the received data.
| ALWAYS_COMPRESS | constant |
public static const ALWAYS_COMPRESS:int = 0A compression strategy that always compresses the data, regardless of whether it saved any space.
| COMPRESSED_TOKEN | constant |
protected static const COMPRESSED_TOKEN:int
| END_TOKEN | constant |
protected static const END_TOKEN:int
| MAX_CHUNK_DATA | constant |
protected static const MAX_CHUNK_DATA:int = 1020The maximum size of our chunks. Whirled enforces a post-AMF3 1024 byte limit, so we want to use all of that. In AMF3, one byte is used to encode "ByteArray", followed by the length, which will be two bytes because 1024-ish is larger than 2^7 but less than 2^14. So the AMF3 encoding takes 3 bytes, plus there's our 1 byte header for each chunk, leaving us 1020 bytes for our chunk size.
| MIN_SEND_WAIT | constant |
protected static const MIN_SEND_WAIT:int = 200The minimum time between sends. This is even fairly aggressive. Using other values may "work" but then certain times they may not work, so you're best off not screwing with this.
| NEVER_COMPRESS | constant |
public static const NEVER_COMPRESS:int = 2A compression strategy that says: don't ever even waste time trying to compress.
| NO_TOKENS | constant |
protected static const NO_TOKENS:int = 0Token constants.
| OBJECT_TOKEN | constant |
protected static const OBJECT_TOKEN:int
| START_TOKEN | constant |
protected static const START_TOKEN:int
| TRY_COMPRESS | constant |
public static const TRY_COMPRESS:int = 1A compression stragegy that tries to compress the data, but only sends the compressed form if it would actually result in sending less chunks.