2012-11-29 11 views
3

온라인 MySQL 데이터베이스, Scaleform 4 (AS3) 및 PHP가 포함 된 웹 서버에 대한 HTTP 요청을 통해 UDKGame에 대한 최고 기록을 게시하고 가져오고 싶습니다. 불행히도이 문서를 고려할 때 가능하지 않을 수도 있습니다 : http://gameware.autodesk.com/documents/gfx_4.0_flash_support.pdf.UDK Scaleform 4 AS3 도메인 간 URL 요청이 가능합니까?

내 GFx Movie Player에서 URLRequest를 보내려고했지만 작동하지 않는 것 같습니다. Heres는 내 AS3 코드 나는 프레임 1에 내 GFX 동영상 플레이어를 위해 사용하고 있습니다 :

getScore(); 

function getScore():void { 
//var url:String = "http://myserver.com/getScore.php"; 
    var request:URLRequest = new URLRequest(url); 
    var requestVars:URLVariables = new URLVariables(); 
    requestVars.foo = "bar"; 
    request.data = requestVars; 
    //request.method = URLRequestMethod.POST; 
    //Security.allowDomain("myserver.com"); 
    //var context:LoaderContext = new LoaderContext(); 
    //context.securityDomain = SecurityDomain.currentDomain 

    var urlLoader:URLLoader = new URLLoader(); 
    urlLoader = new URLLoader(); 
    urlLoader.dataFormat = URLLoaderDataFormat.TEXT; 
    urlLoader.addEventListener(Event.COMPLETE, loaderCompleteHandler, false, 0, true); 
    urlLoader.load(request); 

    } 

function loaderCompleteHandler(e:Event):void { 
    trace(e.target.data); 
    Object(this).response.text= "response:"+e.target.data; 

} 

.dll 인 또는 내 웹 서버에 수동 TCP 연결을 사용을 작성하지 않고 내 목표를 달성하기 위해 어떤 방법이 있나요?

답변

2

불행하게도 UDK (4.0.16)와 함께 제공되는 Scaleform에는 네트워크 지원 기능이 내장되어 있지 않습니다. UDK는 DLL 바인드 또는 다른 것을 통해 문제의 일부를 처리해야합니다. Scaleform 4.2는 네트워킹 지원을 추가했지만 그 버전의 Scaleform은 아직 UDK에 통합되지 않았습니다. 그것은 통합되는 과정에 있지만, 잘하면 곧 보게 될 것입니다.

0

실제로 SF4.0에서는 지원하지 않습니다. SF4.2 일 수도 있고 일 수도 있고 Epic의 Perforce 디포를 통해서만 UE3 라이센시에게 제공됩니다.

언리얼 스크립트로 입력 할 수 있습니다. 그러나 dll이나 TCP 연결을 사용하는 것은 약간 잔인합니다. HttpRequestInterface을 사용하십시오. 다음은 UDK와 함께 제공되는 소스 샘플의 예제입니다. 그것은 꽤 간단하고, 몇 라인만으로 웹 서비스를 호출하는 데 필요한 엄격하게 트리밍 할 수 있습니다.

/** 
* Simple function to illustrate the use of the HttpRequest system. 
*/ 
exec function TestHttp(string Verb, string Payload, string URL, optional bool bSendParallelRequest) 
{ 
    local HttpRequestInterface R; 

    // create the request instance using the factory (which handles 
    // determining the proper type to create based on config). 
    R = class'HttpFactory'.static.CreateRequest(); 
    // always set a delegate instance to handle the response. 
    R.OnProcessRequestComplete = OnRequestComplete; 
    `log("Created request"); 
    // you can make many requests from one request object. 
    R.SetURL(URL); 
    // Default verb is GET 
    if (Len(Verb) > 0) 
    { 
     R.SetVerb(Verb); 
    } 
    else 
    { 
     `log("No Verb given, using the defaults."); 
    } 
    // Default Payload is empty 
    if (Len(Payload) > 0) 
    { 
     R.SetContentAsString(Payload); 
    } 
    else 
    { 
     `log("No payload given."); 
    } 
    `log("Creating request for URL:"@URL); 

    // there is currently no way to distinguish keys that are empty from keys that aren't there. 
    `log("Key1 ="@R.GetURLParameter("Key1")); 
    `log("Key2 ="@R.GetURLParameter("Key2")); 
    `log("Key3NoValue ="@R.GetURLParameter("Key3NoValue")); 
    `log("NonexistentKey ="@R.GetURLParameter("NonexistentKey")); 
    // A header will not necessarily be present if you don't set one. Platform implementations 
    // may add things like Content-Length when you send the request, but won't necessarily 
    // be available in the Header. 
    `log("NonExistentHeader ="@R.GetHeader("NonExistentHeader")); 
    `log("CustomHeaderName ="@R.GetHeader("CustomHeaderName")); 
    `log("ContentType ="@R.GetContentType()); 
    `log("ContentLength ="@R.GetContentLength()); 
    `log("URL ="@R.GetURL()); 
    `log("Verb ="@R.GetVerb()); 

    // multiple ProcessRequest calls can be made from the same instance if desired. 
    if (!R.ProcessRequest()) 
    { 
     `log("ProcessRequest failed. Unsuppress DevHttpRequest to see more details."); 
    } 
    else 
    { 
     `log("Request sent"); 
    } 
    // send off a parallel request for testing. 
    if (bSendParallelRequest) 
    { 
     if (!class'HttpFactory'.static.CreateRequest() 
      .SetURL("http://www.epicgames.com") 
      .SetVerb("GET") 
      .SetHeader("Test", "Value") 
      .SetProcessRequestCompleteDelegate(OnRequestComplete) 
      .ProcessRequest()) 
     { 
      `log("ProcessRequest for parallel request failed. Unsuppress DevHttpRequest to see more details."); 
     } 
     else 
     { 
      `log("Parallel Request sent"); 
     } 
    } 
} 


/** Delegate to use for HttpResponses. */ 
function OnRequestComplete(HttpRequestInterface OriginalRequest, HttpResponseInterface Response, bool bDidSucceed) 
{ 
    local array<String> Headers; 
    local String Header; 
    local String Payload; 
    local int PayloadIndex; 

    `log("Got response!!!!!!! Succeeded="@bDidSucceed); 
    `log("URL="@OriginalRequest.GetURL()); 
    // if we didn't succeed, we can't really trust the payload, so you should always really check this. 
    if (Response != None) 
    { 
     `log("ResponseURL="@Response.GetURL()); 
     `log("Response Code="@Response.GetResponseCode()); 
     Headers = Response.GetHeaders(); 
     foreach Headers(Header) 
     { 
      `log("Header:"@Header); 
     } 
     // GetContentAsString will make a copy of the payload to add the NULL terminator, 
     // then copy it again to convert it to TCHAR, so this could be fairly inefficient. 
     // This call also assumes the payload is UTF8 right now, as truly determining the encoding 
     // is content-type dependent. 
     // You also can't trust the content-length as you don't always get one. You should instead 
     // always trust the length of the content payload you receive. 
     Payload = Response.GetContentAsString(); 
     if (Len(Payload) > 1024) 
     { 
      PayloadIndex = 0; 
      `log("Payload:"); 
      while (PayloadIndex < Len(Payload)) 
      { 
       `log(" "@Mid(Payload, PayloadIndex, 1024)); 
       PayloadIndex = PayloadIndex + 1024; 
      } 
     } 
     else 
     { 
      `log("Payload:"@Payload); 
     } 
    } 
}