diff options
author | Cash Costello <cash.costello@gmail.com> | 2010-10-24 21:08:27 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2010-10-24 21:08:27 +0000 |
commit | da1493b95a2f0b5000a487ae373c9318c58d0b2d (patch) | |
tree | a339b053ade9fb15a1717bdf248a59afc9b3d239 /vendors/uploadify/com/adobe/protocols/dict/util | |
parent | 5161b1c8fdc8ff69005f864a89127fc18db6d4ed (diff) | |
download | elgg-da1493b95a2f0b5000a487ae373c9318c58d0b2d.tar.gz elgg-da1493b95a2f0b5000a487ae373c9318c58d0b2d.tar.bz2 |
partial implementation of flash uploader
Diffstat (limited to 'vendors/uploadify/com/adobe/protocols/dict/util')
-rw-r--r-- | vendors/uploadify/com/adobe/protocols/dict/util/CompleteResponseEvent.as | 25 | ||||
-rw-r--r-- | vendors/uploadify/com/adobe/protocols/dict/util/SocketHelper.as | 49 |
2 files changed, 74 insertions, 0 deletions
diff --git a/vendors/uploadify/com/adobe/protocols/dict/util/CompleteResponseEvent.as b/vendors/uploadify/com/adobe/protocols/dict/util/CompleteResponseEvent.as new file mode 100644 index 000000000..fc552f1b3 --- /dev/null +++ b/vendors/uploadify/com/adobe/protocols/dict/util/CompleteResponseEvent.as @@ -0,0 +1,25 @@ +package com.adobe.protocols.dict.util
+{
+ import flash.events.Event;
+
+ public class CompleteResponseEvent
+ extends Event
+ {
+ private var _response:String;
+
+ public function CompleteResponseEvent()
+ {
+ super(SocketHelper.COMPLETE_RESPONSE);
+ }
+
+ public function set response(response:String):void
+ {
+ this._response = response;
+ }
+
+ public function get response():String
+ {
+ return this._response;
+ }
+ }
+}
\ No newline at end of file diff --git a/vendors/uploadify/com/adobe/protocols/dict/util/SocketHelper.as b/vendors/uploadify/com/adobe/protocols/dict/util/SocketHelper.as new file mode 100644 index 000000000..feb494b31 --- /dev/null +++ b/vendors/uploadify/com/adobe/protocols/dict/util/SocketHelper.as @@ -0,0 +1,49 @@ +package com.adobe.protocols.dict.util
+{
+ import com.adobe.net.proxies.RFC2817Socket;
+ import flash.events.ProgressEvent;
+
+ public class SocketHelper
+ extends RFC2817Socket
+ {
+ private var terminator:String = "\r\n.\r\n";
+ private var buffer:String;
+ public static var COMPLETE_RESPONSE:String = "completeResponse";
+
+ public function SocketHelper()
+ {
+ super();
+ buffer = new String();
+ addEventListener(ProgressEvent.SOCKET_DATA, incomingData);
+ }
+
+ private function incomingData(event:ProgressEvent):void
+ {
+ buffer += readUTFBytes(bytesAvailable);
+ buffer = buffer.replace(/250[^\r\n]+\r\n/, ""); // Get rid of all 250s. Don't need them.
+ var codeStr:String = buffer.substring(0, 3);
+ if (!isNaN(parseInt(codeStr)))
+ {
+ var code:uint = uint(codeStr);
+ if (code == 150 || code >= 200)
+ {
+ buffer = buffer.replace("\r\n", this.terminator);
+ }
+ }
+
+ while (buffer.indexOf(this.terminator) != -1)
+ {
+ var chunk:String = buffer.substring(0, buffer.indexOf(this.terminator));
+ buffer = buffer.substring(chunk.length + this.terminator.length, buffer.length);
+ throwResponseEvent(chunk);
+ }
+ }
+
+ private function throwResponseEvent(response:String):void
+ {
+ var responseEvent:CompleteResponseEvent = new CompleteResponseEvent();
+ responseEvent.response = response;
+ dispatchEvent(responseEvent);
+ }
+ }
+}
\ No newline at end of file |