
API ActionScript 3 class
239
API ActionScript 3 class
These are ActionScript 3 classes for working with RouterOS v3 API. You can take it, edit it and use it as you need.
NOTE - The API implementation is not yet fully tested with large requests or replies. Please update this section if
you have tested this. Also, this ActionScript probably works best in Flash AIR applications (opposed to swf flash
files), since they have no security limitations on socket connections.
Class
// ApiSocket.as
//
// RouterOS API class
// Author: Håkon Nessjøen of Avelia AS
// Date: 2. May 2009
//
package {
import flash.errors.*;
import flash.events.*;
import flash.utils.ByteArray;
import com.adobe.crypto.MD5;
import flash.net.Socket;
public class ApiSocket extends Socket {
static public var RECEIVED:String = "received";
static public var LOGIN:String = "loggedin";
private var cmd:String;
private var doLogin:int;
private var user:String;
private var password:String;
private var returnData:Array;
private var returnPos:int;
private var toread:int;
private var firstRe:int;
private var tag:String;
private var gotDone:Boolean;
private var gotTrap:Boolean;
private var gotFatal:Boolean;
public function ApiSocket(host:String, port:uint) {
super(host, port);
toread = 0;
doLogin = 0;
addEventListener(ProgressEvent.SOCKET_DATA,
socketDataHandler);
}
Komentáře k této Příručce