네트워크 연결을 일정 시간 동안 비틀어 서 내 서버에 너무 많은 압력을 가하지 않는 클래스를 만들려고 노력 중이므로 12 개의 네트 커넥터가 실행되고 있지 않습니다. 주위에 내 코드. 호출 명령을 보낼 수있는 클래스를 원한다면 클래스가 호출을 대기열에 추가 한 다음 대기열에있는 것이 있으면 1 초마다 호출하고 호출하면 호출합니다. 이것은 내가 지금까지 가지고있는 것이다.AS3/Flex 3 비틀린 리모콘 + 대기열
package net
{
import flash.events.TimerEvent;
import flash.net.NetConnection;
import flash.net.Responder;
import flash.utils.Timer;
public class Server
{
private static var gateway:String = "http://localhost/gateway.php";
private static var queue:Vector.<ServerNode>
private static var nc:NetConnection;
private static var instance:Server = null;
private static var res:Responder;
private var timer:Timer;
public function Server(e:ServerEnforcer) {
nc = new NetConnection();
queue = new Vector.<ServerNode>();
timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, execCall);
timer.start();
}
public static function getInstance():Server {
if (instance == null) {
instance = new Server(new ServerEnforcer);
}
return instance;
}
private function execCall(e:Event):void {
if (queue.length > 0) {
var node:ServerNode = queue.pop();
nc.call(node.method, node.res, node.args);
}
}
public function call(method:String, success:Function, failure:Function, ...args):void {
queue.unshift(new ServerNode(method, success, failure, args));
}
private function serverFailure(event:Object):void {
trace("Server Failure : " + event.description);
}
}
}
import flash.net.Responder;
class ServerEnforcer { }
class ServerNode {
public var method:String;
public var success:Function;
public var failure:Function;
public var args:Array;
public var res:Responder
public function ServerNode(_method:String, _success:Function, _failure:Function, _args:Array) {
method = _method;
success = _success;
failure = _failure;
res = new Responder(success, failure);
args = _args;
}
}
는 지금은
Server.getInstance().call("Fetch.getData", parseAllData, onError)
public function parseAllData(event:Object):void {
trace("Victory!");
}
public function onError(event:Object):void {
trace("Error :" + event);
}
절대적으로 아무 일도 발생하지 호출 할 때. 어떤 아이디어가 왜 올바른 방향으로 향하는가? 왜 이것이 작동하지 않는가?
정확히 무엇이 발생합니까? 예를 들어, 디버그 모드에서 프로그램이 서버에 연결되면 반환 된 데이터가 비어있는 것입니까? 응용 프로그램이 전혀 실행되지 않습니까? 적어도 많은 정보를 제공하십시오. – Ryan